Редагувати

Поділитися через


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 Microsoft Entra ID 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 "<username@contoso.com>" -ArmEndpoint "https://management.region.<fqdn>"
    
    Name  Resource Manager Url                            ActiveDirectory Authority
    ----  --------------------                            -------------------------
    username@contoso.com https://management.region.<fqdn> https://login.microsoftonline.com/
    
  2. Run the following cmdlets in the same session:

    $AuthEndpoint = (Get-AzEnvironment -Name "username@contoso.com").ActiveDirectoryAuthority.TrimEnd('/')
    $AADTenantName = "masselfhost.onmicrosoft.com"
    $TenantId = (invoke-restmethod "$($AuthEndpoint)/$($AADTenantName)/.well-known/openid-configuration").issuer.TrimEnd('/').Split('/')[-1]
    Add-AzAccount -EnvironmentName "username@contoso.com" -TenantId $TenantId
    
    Account               SubscriptionName  TenantId                             Environment
    -------               ----------------  --------                             -----------
    username@contoso.com   azure-stack-sub  aaaaaaaa-0000-1111-2222-bbbbbbbbbbbb username@contoso.com
    
  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