次の方法で共有


How to Deploy Marketplace VMs in Azure Stack by ARM template

To build modern applications across cloud and on-premises environments, Azure and Azure Stack can deliver a consistent hybrid cloud platform. Similar to Azure, Azure Stack supports same PowerShell commands, portal experience and similar functionalities. For example, an ARM template which can be deployed in Azure could be deployed to Azure stack without any modification.

In order to deploy Marketplace VMs in Azure Stack by ARM template, we need figure out the corresponding publisher, offer and sku. The easiest way for this is to list all the available images shown below.

Alternatively, we can leverage our existing Azure experience to use Powershell command Get-AzureRmVMImagePublisher, Get-AzureRmVMImageOffer and Get-AzureRmVMImageSku to list all the available publishers, offers and skus. Before that, we need login to Azure Stack, the following is the code for ADFS deployment scenario. Please refer to Get up and running with PowerShell in Azure Stack for more details.

 
Import-Module .\Connect\AzureStack.Connect.psm1

# For Azure Stack development kit, this value is set to https://adminmanagement.local.azurestack.external. To get this value for Azure Stack integrated systems, contact your service provider.
$ArmEndpoint = "https://adminmanagement.local.azurestack.external"

# Register an AzureRM environment that targets your Azure Stack instance
Add-AzureRMEnvironment `
    -Name "AzureStackAdmin" `
    -ArmEndpoint $ArmEndpoint

# Get the Active Directory tenantId that is used to deploy Azure Stack     
$TenantID = Get-AzsDirectoryTenantId `
    -ADFS `
    -EnvironmentName "AzureStackAdmin"

# Sign in to your environment
Add-AzureRmAccount `
    -EnvironmentName "AzureStackAdmin" `
    -TenantId $TenantID

Lastly, we just need to modify the ARM template's storageProfile node, use the imageReference to configure the Markertplace VM shown below. The GitHub repository https://github.com/Azure/AzureStack-QuickStart-Templates/ has contained more templates for reference.

 
"storageProfile": {
          "imageReference": {
            "publisher": "[parameters('imagePublisher')]",
            "offer": "[parameters('imageOffer')]",
            "sku": "[parameters('imageSku')]",
            "version": "latest"
          },
          "osDisk": {
            "name": "osdisk",
            "vhd": {
              "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/', variables('OSDiskName'), '.vhd')]"
            },
            "caching": "ReadWrite",
            "createOption": "FromImage"
          }
        },

Comments

  • Anonymous
    August 05, 2018
    very useful, thanks for sharing!