Unable to connect to Pay as you go subscription from Desktop Powershell

rohit bhatt 1 Reputation point
2022-11-10T17:30:09.48+00:00

Hi ,
I have updagreaded from trial subscriptoon to Pay as you go subscription. Now after updagrading, mu subscription id and tenant id is changed. When I try to connect to Azure sibscription from Windows Powershll using Connect-AzAccount it connect but if shows old tenant id and subscription id and subscription name is also not displayed.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,449 questions
{count} votes

2 answers

Sort by: Most helpful
  1. rohit bhatt 1 Reputation point
    2022-11-10T17:33:54.64+00:00

    I have upgraded from trial subscription to Pay as you go subscription. Now after upgrading, my subscription id and tenant id is changed.
    When I try to connect to Azure subscription from Windows PowerShell using Connect-AzAccount it connect but if shows old tenant id and subscription id and subscription name is also not displayed.

    PS C:\WINDOWS\system32> Connect-AzAccount

    Account SubscriptionName TenantId Environment


    xxxxxx@Karima ben .com 9b98da7a-497b-4a8e-b6e4-6c4d32cd1c42 AzureCloud

    When I try to create resource group, I get below error

    PS C:\WINDOWS\system32> New-AzResourceGroup -Name RG01 -Location "South Central US"
    New-AzResourceGroup : 'this.Client.SubscriptionId' cannot be null.
    At line:1 char:1

    • New-AzResourceGroup -Name RG01 -Location "South Central US"
    • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : CloseError: (:) [New-AzResourceGroup], ValidationException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupCmd
      let

    P.S. Everything works well from Cloud Shell
    I have restarted my PC as a T/s

    Please provide any pointers

    0 comments No comments

  2. Andreas Baumgarten 103.2K Reputation points MVP
    2022-11-10T20:29:54.533+00:00

    Hi @rohit bhatt ,

    maybe the following Az cmdlets are helpful:

    Get-AzContext get the current Azure context of your PowerShell session.
    Get-AzSubcription get all available Azure Subscriptions of you Azure Context
    Set-AzContext -Subcription <name of your Azure subscription switch the context of your PowerShell subscription to the subcription

    If you are connected to the wrong Azure tenant this might be helpful:

    ## Import AZ cmdlets module  
    Import-Module Az   
    ## Disconnet current AZ Sessions  
    do{  
     Disconnect-AzAccount  
     $azureContext = Get-AzContext  
       }  
     until (!$azureContext)  
    

    Connect to you Azure tenant via PowerShell:

    # Connect to your Azure Tenant  
    Connect-AzAccount -Tenant <Azure Tenant ID>  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments