代码之家  ›  专栏  ›  技术社区  ›  Amruta

如何使用ARMTemplate获得跨区域部署

  •  0
  • Amruta  · 技术社区  · 7 年前

    我想使用ARM模板进行跨区域部署。

    示例1: 我有两个资源组的A&B、 资源组有一个存储帐户。我想在B的资源组服务中访问A的存储帐户。

    示例2: 我有两个资源组的A&B、 资源组有一个application insight服务。我想在B的ApiApp服务中访问A的application insight,并在ApiApp“appsettings”中添加插入键。

    我尝试在ARMTemplate中添加以下代码段:

    {
          "apiVersion": "2017-05-10",
          "name": "nestedTemplate",
          "type": "Microsoft.Resources/deployments",
          "resourceGroup": "testresgrp01",
          "properties": {
            "mode": "Incremental",
            "template": {
              "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
              "contentVersion": "1.0.0.0",
              "parameters": {},
              "variables": {},
              "resources": [
                {
                  "type": "Microsoft.Insights/components",
                  "name": "[parameters('appinsightname')]",
                  "apiVersion": "2015-06-15",
                  "location": "South Central US",
                  "properties": {
    
                  }
                }
              ]
            },
            "parameters": {}
          }
        },
        {
          "type": "Microsoft.Insights/components",
          "name": "[parameters('appinsightname')]",
          "apiVersion": "2015-06-15",
          "location": "South Central US",
          "properties": {
    
          }
        } 
    

    但本节在部署时出错,并给出以下错误:

    New-AzureRmResourceGroupDeployment :  - Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The 
    template resource 'nestedTemplate' at line '224' and column '10' is invalid. The api-version '2016-07-01' used to deploy the 
    template does not support 'ResourceGroup' property. Please use api-version '2017-05-10' or later to deploy the template.
    

    如果我删除 “resourceGroup”:“testresgrp01”, 第节,资源部署在resourcegroup中创建一个新服务。

    如何解决这个问题?

    1 回复  |  直到 7 年前
        1
  •  0
  •   4c74356b41    7 年前

    我很确定你的Azure Powershell模块已经过时,请将其更新到最新版本,然后重试。

    我通常会删除所有模块并从头开始安装,以确保没有冲突。