Restrict access to Office 365 using Conditional Access and Cloud SWG Dedicated IPs.
search cancel

Restrict access to Office 365 using Conditional Access and Cloud SWG Dedicated IPs.


Article ID: 257118


Updated On:


Cloud Secure Web Gateway - Cloud SWG


How do I restrict access to Office 365 to users that are using Cloud SWG? 

Can I require users to go through Cloud SWG in order to get to Office 365?


Dedicated IP address feature enabled.

Office 365 (O365) with Conditional Access enabled. 


Follow these steps to restrict access to O365 from Cloud SWG dedicated IP addresses.

1. Add the three highlighted O365 login domains to the dedicated IP address configuration using the Cloud SWG Portal, as shown below:



2. Click the “Download Dedicated IP Addresses” link highlighted above and note the IP addresses defined in the JSON file.

Please find an example of the file format below which includes custom IP addresses assigned exclusively to your tenant. Your IP addresses will be different from those in the example. 



3. From the Azure Portal, define a conditional access policy that will only allow access from the Cloud SWG dedicated IP addresses above.

  • From the Azure Active Directory -> Security -> Named Location
    • Add a new IP address location with the Cloud SWG IP addresses unique to your tenant as shown below
    • Make sure that the 'Mark as trusted location' flag is enabled


  • From the Azure Active Directory -> Security -> Conditional Access configuration
    • Create a new conditional access policy with the following settings to block access from all locations except for the ones we need


  •   Add any O365 Application so that the required recondition is triggered

  •   Under the conditions tab, include ALL locations with the exception of the Cloud SWG IP address named location defined in the initial step above

  •  Under the grant tab, BLOCK access for all locations (except Cloud SWG trusted locations)
  • Save all changes

Additional Information

Additional information:

1. Microsoft documentation on restricting access to O365 based on egress IP addresses:
2. Sample error messages returned when O365 access is blocked by a conditional policy: - error messages!
3. Documentation on the O365 login URLs: