Connect-AzureRmAccount - Cannot connect to Azure - azure

While trying to connect Azure from Powershell getting below error:
PS H:\> Connect-AzureRmAccount
Connect-AzureRmAccount : An error occurred while sending the request.
At line:1 char:1
+ Connect-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzureRmAccount], HttpRequestException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

Couple of things to try :
Sometime , powershell cmdlet doesn't give proper error message as it suppressed it , to get the actual error you can try executing with -debug attribute or you can try using DebugPreference like below.
$DebugPreference = "Continue"
Write-Debug -Message "Hello, World"
Alternatively ,Connect-AzureRMAccount cmdlet used TLS 1.0 by default for connecting to azure and sometime it gets blocked by the organization security policy,
Can you setting up something like below:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Additional reference:
Connect-AzureRmAccount : accessing_ws_metadata_exchange_failed
Hope it helps.

Related

Get-AzDataFactoryV2Pipeline : Unable to deserialize the response

I am trying to fetch the Data Factory Pipeline Information with the help of following simple command:
Get-AzDataFactoryV2Pipeline -ResourceGroupName $resourceGroupName -DataFactoryName $dataFactoryName
However, I am getting this Error. I have also update my Az.Data Factory module to the latest one.
Get-AzDataFactoryV2Pipeline : Unable to deserialize the response.
At line:1 char:1
+ Get-AzDataFactoryV2Pipeline -ResourceGroupName $resourceGroupName -Da ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzDataFactoryV2Pipeline], SerializationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.DataFactoryV2.GetAzureDataFactoryPipelineCommand
Please give your valuable suggestions to fix this ?
This command works for me with the Az.DataFactory 1.11.0, please open a new powershell session to try again.

What does Object reference not set to an instance of an object error mean when using Add-AzServiceFabricClusterCertificate?

I'm trying to add a new secondary cert to the service fabric, however I receive the following error. does any one have any pointers?
PS C:\WINDOWS\system32> Add-AzServiceFabricClusterCertificate -ResourceGroupName '******' -Name '********' -SecretIdentifier '*************'
Add-AzServiceFabricClusterCertificate : Object reference not set to an instance of an object.
At line:1 char:1
+ Add-AzServiceFabricClusterCertificate -ResourceGroupName '****
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzServiceFabricClusterCertificate], NullReferenceException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.ServiceFabric.Commands.AddAzureRmServiceFabricClusterCertificate
I could not reproduce your issue, it works on my side.
Try to update the Az.ServiceFabric with the command below, my version is 2.0.1.
Update-Module -Name Az.ServiceFabric -Force
In azure keyvault, I use a self-signed certificate, make sure you use the SecretIdentifier below.
Then use the powershell and check the result in the portal.
Add-AzServiceFabricClusterCertificate -ResourceGroupName '<group-name>' -Name 'joyfabric' -SecretIdentifier 'https://joykeyvault.vault.azure.net/secrets/cer135/23c6706daeab47e59caca2431ad96a1c'

Get-AzureWebSite : Requested value 'PremiumV2' was not found

I added a new Premium V2 app service plan. Now when running Get-AzureWebSite in PowerShell I'm getting the following error message:
get-azurewebsite : Requested value 'PremiumV2' was not found.
At line:1 char:1
+ get-azurewebsite
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Get-AzureWebsite], ArgumentException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Websites.GetAzureWebsiteCommand
What is the error about?
The old CmdLets are no longer well supported, and don't know about new features like Premium V2.
Try using the ARM based CmdLets instead, like Get-AzureRmWebApp.

Azure PowerShell Login: browser based authentication dialog failed to complete

I'm getting this error when running Login-AzureRmAccount in PowerShell:
Login-AzureRmAccount : The browser based authentication dialog failed to complete. Reason: The request could not be
processed by the server due to invalid syntax.
At line:1 char:1
+ Login-AzureRmAccount
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-AzureRmAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.Azure.Common.Authentication.AadAuthenticationFailedException,Microsoft.Azure.Comm
ands.Profile.AddAzureRMAccountCommand
I see the login window pop up briefly, but it closes immediately and this error message displays.
It turned out my proxy settings were preventing me from connecting to the internet. Once I corrected my proxy settings I was able to log into Azure as expected. Not sure what the "invalid syntax" error is all about...
Run add-azureaccount
it will ask for credential, enter the credential.
then run Connect-azAccount it will again ask for the credential, provide the credentials and it will work fine

ServiceManagement API exception calling Azure cmdlets from powershell

I'm trying to create VM using Azure Powershell. So i've imported Azure pulish settings file from portal. When i run any of the commands like "Get-AzureLocation" or "Get-AzureVM" etc i'm getting below exception. Need any help or suggestions.
PS C:\Users\YVM> Get-AzureVM
Get-AzureVM : "An exception occurred when calling the ServiceManagement API. HTTP Status Code: 407. Service Error Code: . Message: . Operation Tracking ID: ."
At line:1 char:1 + Get-AzureVM + ~~~~~~~~~~~ + CategoryInfo : CloseError: (:) [Get-AzureVM], ServiceManagementClientException + FullyQualifiedErrorId : Microsoft.WindowsAzure.Management.ServiceManagement.IaaS.GetAzureVMCommand
Can you run the command with the -Debug option, or using $DebugPreference=Continue. This should provide a debug trace with some more details about where the call is failing and the exact message you're getting back.

Resources