English 中文(简体)
A. 模块式
原标题:Azure ARM template with array as parameter

我正试图在“ARM”模板中复印机功能,下面是我拥有的资源部分。

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"resourceGroupsName": {
  "type": "string"
},
"clusterName": {
  "type": "string"
},
"clusterLoginUserName": {
  "type": "string"
},
"clusterLoginPassword": {
  "type": "securestring"
},
"sshUserName": {
  "type": "string"
},
"sshPassword": {
  "type": "securestring"
},
"location": {
  "type": "string"
},
"clusterType": {
  "type": "string",
  "defaultValue": "spark"
},
"clusterVersion": {
  "type": "string"
},
"sparkVersion": {
  "type": "string"
},
"clusterWorkerNodeCount": {
  "type": "int",
  "defaultValue": 2
},
"virtualNetworkName": {
  "type": "string"
},
"subnetName": {
  "type": "string"
},
"vnetResourceGroupName": {
  "type": "string"
},
"clusterStorageAccountName": {
  "type": "string"
},
"dataStorageAccountName": {
  "type": "string"
},
"clusterStorageContainerName": {
  "type": "string"
},
"externalStorageAccounts": {
  "type": "array"
},
"storageAccountResourceGroupName": {
  "type": "string"
},
"headNodeSize": {
  "type": "string"
},
"workerNodeSize": {
  "type": "string"
},
"edgeNodeSize": {
  "type": "string"
},
"dbServerName": {
  "type": "string"
},
"hivedbName": {
  "type": "string",
  "metadata": { "description": "Name of the database where metadata will be stored" }
},
"ooziedbName": {
  "type": "string",
  "metadata": { "description": "Name of the database where metadata will be stored" }
},
"dbuser": {
  "type": "string",
  "metadata": { "description": "User Name of the database server where metadata will be stored" }
},
"dbpassword": {
  "type": "securestring",
  "metadata": { "description": "Password of the database where metadata will be stored" }
},
"collation": {
  "type": "string",
  "defaultValue": "SQL_Latin1_General_CP1_CI_AS",
  "metadata": {
    "description": "The database collation for governing the proper use of characters."
  }
},
"edition": {
  "type": "string",
  "defaultValue": "Standard",
  "allowedValues": [
    "Basic",
    "Standard",
    "Premium"
  ],
  "metadata": {
    "description": "The type of database to create."
  }
},
"maxSizeBytes": {
  "type": "string",
  "defaultValue": "1073741824",
  "metadata": {
    "description": "The maximum size, in bytes, for the database"
  }
},
"requestedServiceObjectiveName": {
  "type": "string",
  "defaultValue": "S1",
  "allowedValues": [
    "Basic",
    "S0",
    "S1",
    "S2",
    "P1",
    "P2",
    "P3"
  ],
  "metadata": {
    "description": "Describes the performance level for Edition"
  }
},
"omsWorkspace": {
  "type": "string",
  "metadata": {
    "description": "OMS Workspace ID"
  }
},
"omsResourceGroup": {
  "type": "string",
  "metadata": {
    "description": "OMS Workspace Key"
  }
},
"Environment": {
  "type": "string",
  "allowedValues": [
    "dev",
    "qa",
    "stage",
    "prod"
  ],
  "metadata": {
    "description": "The environment that the resources will be tagged with (dev, test, stage, prod)."
  }
},
"ProjectName": {
  "type": "string",
  "metadata": {
    "description": "A name for the project or company that this template is being provisioned for (used for tagging)."
  }
}
},
"variables": {
"dbServerName": "[concat(parameters( dbServerName ), .database.windows.net )]",
"defaultApiVersion": "2015-05-01-preview",
"clusterApiVersion": "2015-03-01-preview",
"vnetID": "[concat(resourceId(parameters( vnetResourceGroupName ), Microsoft.Network/virtualNetworks , parameters( virtualNetworkName )))]",
"subnet1Ref": "[concat(variables( vnetID ), /subnets/ , parameters( subnetName ))]",
"applicationName": "[concat( edgenode )]"
},
"resources": [
  {
    "name": "[parameters( clusterName )]",
    "type": "Microsoft.HDInsight/clusters",
    "location": "[resourceGroup().location]",
    "apiVersion": "[variables( clusterApiVersion )]",
    "dependsOn": [],
    "tags": {
      "Environment": "[parameters( Environment )]",
      "Project": "[parameters( ProjectName )]"
    },
    "properties": {
      "clusterVersion": "[parameters( clusterVersion )]",
      "osType": "Linux",
      "tier": "standard",
      "clusterDefinition": {
        "kind": "[parameters( clusterType )]",
        "componentVersion": {
                "Spark": "[parameters( sparkVersion )]"
        },
        "configurations": {
          "gateway": {
            "restAuthCredential.isEnabled": true,
            "restAuthCredential.username": "[parameters( clusterLoginUserName )]",
            "restAuthCredential.password": "[parameters( clusterLoginPassword )]"
          },
          "core-site": {
          },
          "hive-site": {
            "javax.jdo.option.ConnectionDriverName": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
            "javax.jdo.option.ConnectionURL": "[concat( jdbc:sqlserver:// , variables( dbServerName ), ;database= , parameters( hivedbName ), ;encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300 )]",
            "javax.jdo.option.ConnectionUserName": "[parameters( dbuser )]",
            "javax.jdo.option.ConnectionPassword": "[parameters( dbpassword )]"
          },
          "hive-env": {
            "hive_database": "Existing MSSQL Server database with SQL authentication",
            "hive_database_name": "[parameters( hivedbName )]",
            "hive_database_type": "mssql",
            "hive_existing_mssql_server_database": "[parameters( hivedbName )]",
            "hive_existing_mssql_server_host": "[variables( dbServerName )]",
            "hive_hostname": "[variables( dbServerName )]"
          },
          "oozie-site": {
            "oozie.service.JPAService.jdbc.driver": "com.microsoft.sqlserver.jdbc.SQLServerDriver",
            "oozie.service.JPAService.jdbc.url": "[concat( jdbc:sqlserver:// , variables( dbServerName ), ;database= , parameters( ooziedbName ), ;encrypt=true;trustServerCertificate=true;create=false;loginTimeout=300 )]",
            "oozie.service.JPAService.jdbc.username": "[parameters( dbuser )]",
            "oozie.service.JPAService.jdbc.password": "[parameters( dbpassword )]",
            "oozie.db.schema.name": "oozie"
          },
          "oozie-env": {
            "oozie_database": "Existing MSSQL Server database with SQL authentication",
            "oozie_database_name": "[parameters( ooziedbName )]",
            "oozie_database_type": "mssql",
            "oozie_existing_mssql_server_database": "[parameters( ooziedbName )]",
            "oozie_existing_mssql_server_host": "[variables( dbServerName )]",
            "oozie_hostname": "[variables( dbServerName )]"
          }
        }
      },
      "storageProfile": {
        "copy": [
            {
                "name": "storageaccounts",
                "count": "[length(parameters( externalStorageAccounts ))]",
                "input": {
                    "name": "[concat(parameters( externalStorageAccounts )[copyIndex( storageaccounts )].name, .blob.core.windows.net )]",
                    "isDefault": "[parameters( externalStorageAccounts )[copyIndex( storageaccounts )].isDefault]",
                    "container": "[parameters( externalStorageAccounts )[copyIndex( storageaccounts )].container]",
                    "key": "[listKeys(resourceId(parameters( externalStorageAccounts )[copyIndex( storageaccounts )].resourceGroupsName, Microsoft.Storage/storageAccounts , parameters( externalStorageAccounts )[copyIndex( storageaccounts )].name), variables( defaultApiVersion )).key1]",
                }
            }
        ]
      },
    "computeProfile": {
        "roles": [
          {
            "name": "headnode",
            "targetInstanceCount": "2",
            "hardwareProfile": {
              "vmSize": "[parameters( headNodeSize )]"
            },
            "osProfile": {
              "linuxOperatingSystemProfile": {
                "username": "[parameters( sshUserName )]",
                "password": "[parameters( sshPassword )]"
              }
            },
            "virtualNetworkProfile": {
              "id": "[variables( vnetID )]",
              "subnet": "[variables( subnet1Ref )]"
            },
            "scriptActions": []
          },
          {
            "name": "workernode",
            "targetInstanceCount": "[parameters( clusterWorkerNodeCount )]",
            "hardwareProfile": {
              "vmSize": "[parameters( workerNodeSize )]"
            },
            "osProfile": {
              "linuxOperatingSystemProfile": {
                "username": "[parameters( sshUserName )]",
                "password": "[parameters( sshPassword )]"
              }
            },
            "virtualNetworkProfile": {
              "id": "[variables( vnetID )]",
              "subnet": "[variables( subnet1Ref )]"
            },
            "scriptActions": []
          }
        ]
      }
    }
  }
],
"outputs": {
"cluster": {
  "type": "object",
  "value": "[reference(resourceId( Microsoft.HDInsight/clusters ,parameters( clusterName )))]"
 }
}
}

https://gist.github.com/anonymous/fa27714ea74bbcecafbbfa1380b2308a

我通过参数<代码>外部照相/编码>,作为阵列,细节如下:

"externalStorageAccounts": {
  "value": [
    { "name": "sparkstg", "container": "sparkdata", "isDefault": "true","resourceGroupsName": "Spark" },
    { "name": "s1rg", "container": "blank", "isDefault": "false","resourceGroupsName": "s1rg" },
    { "name": "s2rg", "container": "blank", "isDefault": "false","resourceGroupsName": "s2rg" },
    { "name": "s3rg", "container": "blank", "isDefault": "false","resourceGroupsName": "s3rg" },
    { "name": "s4rg", "container": "blank", "isDefault": "false","resourceGroupsName": "s3rg" }
  ]
}

但使模板错误无效

想理解我在这里的错误。

问题回答

您需要从资源定义中删除<代码>copy,并设立以下小组:

"storageProfile": {
    "copy": [
        {
            "name": "storageaccounts",
            "count": "[length(parameters( externalStorageAccounts ))]",
            "input": {
                "name": "[concat(parameters( externalStorageAccounts )[copyIndex( storageaccounts )].name, .blob.core.windows.net )]",
                "isDefault": "[parameters( externalStorageAccounts )[copyIndex( storageaccounts )].isDefault]",
                "container": "[parameters( externalStorageAccounts )[copyIndex( storageaccounts )].container]",
                "key": "[listKeys(resourceId(parameters( externalStorageAccounts )[copyIndex( storageaccounts )].resourceGroupsName, Microsoft.Storage/storageAccounts , parameters( externalStorageAccounts )[copyIndex( storageaccounts )].name), variables( defaultApiVersion )).key1]"
            }
        }
    ]
}

instead of you existing storageProfile

基本上,你正在做些什么——试图创造同样的资源X倍,以及你需要做的是复制单一财产X倍。

奥凯在绕过这个轨道后,我可以向您保证,因为单key是一种运行时间的职能,财产复制是一种汇编时间功能。 因此,这不可能奏效(这在我看来只是一).。

你的工作可以先把钥匙带走,并直接添加到阵列中,因此,你们的阵列希望:

"externalStorageAccounts": {
  "value": [
    { "name": "salsbx01sparkstg", "container": "dlid01spk21", "isDefault": "true","key": "xxx" },
    ...
    { "name": "s4rg", "container": "blank", "isDefault": "false","key": "xxx" }
  ]
},

我认为,这可能与我们在整个数据中心重新推出的固定装置有关——你能否尝试在西部署(如果可能,我知道你有某些先决条件),并看看这是否可行? 我能够验证该模板(上周可能)。

这一解决办法对我来说是行之有效的。

{
  "type": "Microsoft.Compute/disks",
  "name": "[concat(parameters( VmName ), copyIndex(),  -dataDisk )]",
  "apiVersion": "2017-03-30",
  "location": "[resourceGroup().location]",
  "sku": {
    "name": "Standard_LRS"
  },
  "copy": {
    "name": "VMDataDisksLoop",
    "count": "[parameters( numberOfNodes )]"
  },
  "properties": {
    "creationData": {
      "createOption": "Empty"
    },
    "diskSizeGB": 128
  }
}

定出一定数量的软磁盘,每 no一个





相关问题
Windows Azure WorkerRole response

I am working on an Azure demo to run Powershell in a worker role. In my web role I add the name of the Powershell script which is to be run to a CloudQueue object. I can print the script output to ...

Windows Azure WebRole stuck in a deployment loop

I ve been struggling with this one for a couple of days now. My current Windows Azure WebRole is stuck in a loop where the status keeps changing between Initializing, Busy, Stopping and Stopped. It ...

Getting a token for Windows Azure

We are looking at Windows Azure, but getting a token appears to be hard now, at least that s what I m seeing in web searches. Anyone tried it or know how to accelerate that process? Any idea how long ...

Developing Azure .Net 4.0 Applications

Presently .Net 4.0 is not supported on Azure. This thread indicates that you will not be able to use .Net 4.0 with VS 2010 until it is supported in the cloud. http://social.msdn.microsoft.com I d ...

.NET 4.0 on Windows Azure?

My google-fu is failing me on this one. As a possible solution to Unit Testing .NET 3.5 projects using MStest in VS2010 (but I ve put this in a seperate question because it s kind of unrelated): Is ...

热门标签