Deploy a storage account to Azure Stack Hub in Visual Studio Code

In this article, you can learn how to deploy a storage account to Azure Stack Hub using the Azure Storage extension in Visual Studio Code. You can use Azure directly from Visual Studio Code through extensions. You will need to update your Visual Studio Code settings.

Visual Studio Code is a lightweight editor for building and debugging cloud applications. Using the Azure Account extension to sign in, you can see their current storage accounts, blobs, and deploy a new one to their Azure Stack Hub subscription. Using this extension, you can:

  • Explore, create, delete Blob containers, queues, tables, and storage accounts.
  • Create, edit, and delete block Blobs and files.
  • Upload and download Blobs, files, and folders.
  • Access connection string and primary key.
  • Open in storage explorer for memory or computationally heavy tasks, or for page and append Blob support.

The extension works with both Azure Active Directory (Azure AD) and Active Directory Federated Services (AD FS) identity managers.

Prerequisites for the extension

Get your credentials

In this section, you will use your credentials to get your tenant ID. You will need your Azure Stack Hub Resource Manager URL and tenant ID.

The Azure Stack Hub Resource Manager is a management framework that allows you to deploy, manage, and monitor Azure resources.

  • The Resource Manager URL for the Azure Stack Development Kit (ASDK) is: https://management.local.azurestack.external/
  • The Resource Manager URL for an integrated system is: https://management.region.<fqdn>/, where <fqdn> is your fully qualified domain name.
  1. Open PowerShell with an elevated prompt. And run the following cmdlets:

    Add-AzEnvironment -Name "<>" -ArmEndpoint "https://management.region.<fqdn>"
    Name  Resource Manager Url                            ActiveDirectory Authority
    ----  --------------------                            ------------------------- https://management.region.<fqdn>
  2. Run the following cmdlets in the same session:

    $AuthEndpoint = (Get-AzEnvironment -Name "").ActiveDirectoryAuthority.TrimEnd('/')
    $AADTenantName = ""
    $TenantId = (invoke-restmethod "$($AuthEndpoint)/$($AADTenantName)/.well-known/openid-configuration").issuer.TrimEnd('/').Split('/')[-1]
    Add-AzAccount -EnvironmentName "" -TenantId $TenantId
    Account               SubscriptionName  TenantId                             Environment
    -------               ----------------  --------                             -----------   azure-stack-sub  6d5ff183-b37f-4a5b-9a2f-19959cb4224a
  3. Make a note of the tenant ID. You will need it when adding the JSON section that configures the Azure Storage extension.

Set up the Azure Storage extension

  1. Open VS Code.

  2. Select Extensions on the left side.

  3. Download and install the Azure Storage extension for Visual Studio Code. When complete, you will see an Azure icon in the activity bar.

  4. Connect to Azure Stack Hub using the Azure Account extension. Select Azure: Sign In to Azure Cloud to connect to your Azure Stack Hub account.

  5. Add the URL for your Azure Stack Hub Resource Manager, and then add the Tenant ID.

  6. Select the Azure icon in the Activity bar in Visual Studio Code. Expand the storage group.

  7. Under Resources, right-click Storage accounts, and then select Create Storage account....

    Screenshot showing how to add storage

  8. Enter a unique name for the storage account.

  9. Select a location for the storage account to be deployed.

  10. Once the storage account is deployed, you can select it to copy the connection string, create Blob containers, queues, and tables. Users can view all of these resources inside of Visual Studio Code.

  11. Right-click the storage account and select Delete Storage Account to remove it from the subscription.

Next steps

Set up a development environment in Azure Stack Hub