Connecting to Exchange Web Services for Office 365 reports multiple dependency failures in Application Insights.
The code below actually works and does return folder and message results. But we're constantly seeing huge numbers of failures reported by Application Insights when we hit the endpoints.
service = new ExchangeService(ExchangeVersion.Exchange2013_SP1, TimeZoneInfo.Local);
service.Credentials = new WebCredentials(account, password, "domain_foo");
service.Url = new Uri(@"https://outlook.office365.com/EWS/Exchange.asmx");
I would expect this to just not fail, but the fact that we get mailbox data back AND see dependency call failures is just bizarre. Application Insights doesn't allow us to drill down further to see what the problem was, but we're seeing a failure rate of 50/s to 75/s
If the request are not failing then 401's are normal during credential negotiation eg the first request will return a 401 as a Challenge with the headers telling the requester what authentication is available on the server see https://blogs.msdn.microsoft.com/benjaminperkins/2011/09/14/integrated-windows-authentication-with-negotiate/
If you using Office365 then don't use Basic authentication its going away next year https://techcommunity.microsoft.com/t5/Exchange-Team-Blog/Upcoming-changes-to-Exchange-Web-Services-EWS-API-for-Office-365/ba-p/608055 you should look to use OAuth instead or even look at using the Graph if you can.