In azure power shell while creating new storage account it was showing an error like no subscription found even i have a subsccription.

sowmya nekkanti 0 Reputation points
2024-11-27T05:10:13.47+00:00

In azure power shell while creating new storage account it was showing an error like "no subscription found", even i have a subsccription.

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,692 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Babafemi Bulugbe 3,785 Reputation points MVP
    2024-11-27T06:03:16.2033333+00:00

    Hello @Sowmya Nekkanti

    Thank you for raising your question in the Microsoft Q&A Community.

    One of the possible reasons is that you are authenticating against the wrong tenant. When authenticating from Powershell, include the tenant flag and probably the subscription flag using the command below.

    Connect-AzAccount -Tenant 'xxxx-xxxx-xxxx-xxxx' -SubscriptionId 'yyyy-yyyy-yyyy-yyyy'
    
    Account                SubscriptionName TenantId                Environment
    -------                ---------------- --------                -----------
    azureuser@contoso.com  Subscription1    xxxx-xxxx-xxxx-xxxx     AzureCloud
    

    You should have the same result as shown above with your tenant ID and subscription ID.

    https://learn.microsoft.com/en-us/powershell/module/az.accounts/connect-azaccount?view=azps-13.0.0

    You can check if there are Subscriptions in the tenant if you do not want to use the Subscription flag by running the command below.

    Get-AzSubscription
    
    

    Alternatively, you can check using the Azure Cloud Shell which automatically redirects you to the environment once you are logged in on the Portal.

    User's image

    Let me know if further assistance is required.

    Babafemi

    0 comments No comments

  2. Deepanshukatara-6769 11,935 Reputation points
    2024-11-27T06:05:09.4133333+00:00

    Hello Sowmya, Welcome to MS Q&A

    The error "no subscription found" typically occurs when Azure PowerShell is not properly authenticated or the subscription context is not set. Here are a few steps to troubleshoot and resolve this issue:

    1. Authenticate to Azure: Ensure you are authenticated to Azure using the Connect-AzAccount command
            Connect-AzAccount
            
         
         
      
    2. Check Subscription: Verify that you have a subscription by listing all subscriptions associated with your account.
            Get-AzSubscription
            
         
         
      
    3. Set the Subscription Context: If you have multiple subscriptions, you need to set the context to the correct subscription
            Set-AzContext -SubscriptionId "your-subscription-id"
            
         
         
         
         
      
    4. Verify the Context: Confirm that the context is set to the correct subscription.
            Get-AzContext
            
         
         
      
    5. Create the Storage Account: After setting the context, you can proceed to create the storage account
            New-AzStorageAccount -ResourceGroupName "your-resource-group" -Name "yourstorageaccountname" -Location "your-location" -SkuName "Standard_LRS"
            
         
         
      

    By following these steps, you should be able to resolve the "no subscription found" error and successfully create a new storage account using Azure PowerShell

    Please let us know if any questions

    Kindly accept answer if it helps

    Thanks
    Deepanshu

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.