Hi All,
I had the exact same problem, and thought i'd share the fix.
If you're receiving:
System.Exception: Exception calling SAS. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it:
Ensure you have a system proxy set by running: netsh winhttp set proxy my.proxy.server:8080
If you're receiving:
System.Exception: Exception calling SAS. ---> System.Net.WebException: The remote server returned an error: (401) Unauthorized.
You either have an invalid or missing Azure MFA certificate - check your "computer" certificate store and look for a "O365tenantName**.onmicrosoft.com**" certificate.
If you're fortunate enough to have more than one ADFS server, export the certificate from the working server (with private key), and import on any servers missing the cert.
If you don't have the certificate, you can re-generate as Tspoh mentioned (previous post), by running:
New-AdfsAzureMfaTenantCertificate -TenantID <your tenant ID> | Out-File amfacert.cer
P.S. if you re-generate and have more than one ADFS server, ensure you export/import the certificate to any additional servers.
hope this helps others! :)
regards,
Kurt.