Azure: The request was aborted: Could not create SSL/TLS secure channel.

Aer you running in to the following error when trying to login to Azure?

Add-AzureRmAccount : accessing_ws_metadata_exchange_failed: Accessing WS metadata exchange failed: The request was
aborted: Could not create SSL/TLS secure channel.
At line:5 char:1
+ Add-AzureRmAccount -Credential $AzureAutomationCredential
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.AddAzureRMAccountCommand

This may happen if your company is redirecting your login, and has disabled TLS 1.0/1.1 that is used by default by the Automation session.

You can add the following line to the top of your powershell code to get arround this issue:
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol::TLS12

This issue is currently active with the following modules/tools:
– Azure Automation (10/8/2018)
– AzureRm Module version 6.9.0
– AZ Module version 0.2.2

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.