If you are an Office 365 customer or are planning to soon migrate, a key configuration is ensuring that your firewall and proxy infrastructure is configured to allow this traffic through. In the case of a Web Proxy for the best performance, and if you are using trusted locations in conditional access, you want to allow direct traffic.
The challenge may be if your software, or your information security department requires that you use IP Addresses only and not friendly URL names. These IP addresses can change and can affect your O365 services. The following script demonstrations how you can pull that information programmatically. It would not be a big leap to automate your firewall and proxy configurations, or at least to notify you when they have changed.