【问题标题】:Is there a way to execute ARM template which is under Templates in Azure via PowerShell/CLI有没有办法通过 PowerShell/CLI 执行 Azure 中的模板下的 ARM 模板
【发布时间】:2021-09-07 18:31:02
【问题描述】:

我创建了一个 ARM 并保存在我的 Azure 门户帐户中的模板下。 现在我打算通过 Powershell/CLI 运行保存的 arm 模板。

如果 ARM 模板保存在我的本地 m/c 中,那么我可以轻松上传它们并从 powershell 运行。但我的问题是如何使用 powershell 命令运行保存在模板下的门户中的模板

【问题讨论】:

标签: powershell azure-resource-manager


【解决方案1】:

我们已经在本地环境中进行了重现,您无法使用 Azure CLI 或 PowerShell 部署那些保存的 ARM 模板。

如果这些模板保存为模板规范,您可以使用 PowerShell 或 Azure CLI 部署这些 arm 模板

 $id = (Get-AzTemplateSpec -Name storageSpec -ResourceGroupName templateSpecsRg -Version 1.0).Version.Id
    
    New-AzResourceGroupDeployment `
      -ResourceGroupName demoRG `
      -TemplateSpecId $id
  • AzureCLI 部署 arm 模板规范的命令:
id = $(az ts show --name storageSpec --resource-group templateSpecRG --version "1.0" --query "id")
        
        az deployment group create \
          --resource-group demoRG \
          --template-spec $id

这里是参考,关于ARM template spec的信息

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-02
    • 1970-01-01
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多