Azure PowerShell RRS feed

  • Question

  • I connect to Azure using powershell.

    I am able to connect once or twice with below command, but in 3rd attempt i gives me error. I have tried clear-azcontext, disconnect-azaccount. But still the error comes in 3rd or 4th attempt of running below command. 


    Connect-AzAccount -Subscription ***-***-Tenant ***-*** -Environment ***-Credential $Credential


    Connect-AzAccount : An error occurred while sending the request

    At line:1 char:1
    + Connect-AzAccount -Subscription ***-*** -Tenant ***-***...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : CloseError: (:) [Connect-AzAccount], HttpRequestException
        + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

    Manvendra Bele

    Monday, July 15, 2019 2:20 PM

All replies

  • Hi Manvendra,

    Thanks for reaching out!

    I tried running the command multiple times and did not encounter any such issue.

    Can you please explain more on what you are trying to achieve by running the same command multiple times?

    Are you switching between users/tenants/subscriptions?

    I used the below script:

    $Credential = Get-Credential
    Connect-AzAccount -Credential $Credential -Tenant "<tenant_id>" -Subscription "<subscription_id>" -Environment <environment_name>

    Make sure to re-generate the Credential when switching to another user.

    Hope this helps!

    Friday, July 19, 2019 1:00 PM