- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用恢复服务,在其中我可以通过 ARM 模板自动将 VM 添加到 Azure 备份。我已经在单机部署上成功完成了此操作,但我尝试在部署多个虚拟机时导入它。
这是我得到帮助的地方: https://www.francoisdelport.com/2017/03/automating-azure-vm-backups-using-arm-templates/
和
Azure ARM JSON template - Add VM to Recovery Services Vault in different Resource Group
这是我正在工作的单个部署的片段
{
"apiVersion": "2017-05-10",
"name": "nestedTemplate",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "Env1",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2016-06-01",
"name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', parameters('vmPrefix'), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', parameters('vmPrefix'))]",
"location": "[resourceGroup().location]",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"properties": {
"protectedItemType": "Microsoft.Compute/virtualMachines",
"policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
"sourceResourceId": "[resourceId(subscription().subscriptionId, parameters('vmRsg'), 'Microsoft.Compute/virtualMachines', parameters('vmPrefix'))]"
}
}
]
}
}
}
现在我尝试以 copyIndex 形式使用它来进行虚拟机部署,这是我一直在测试的代码:
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"adminUsername": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Username for the Virtual Machine."
}
},
"adminPassword": {
"type": "securestring",
"metadata": {
"description": "Password for the Virtual Machine."
}
},
"dnsNameForPublicIP": {
"type": "string",
"minLength": 1,
"metadata": {
"description": "Globally unique DNS Name for the Public IP used to access the Virtual Machine."
}
},
"windowsOSVersion": {
"type": "string",
"defaultValue": "2012-R2-Datacenter",
"allowedValues": [
"2008-R2-SP1",
"2012-Datacenter",
"2012-R2-Datacenter"
],
"metadata": {
"description": "The Windows version for the VM. This will pick a fully patched image of this given Windows version. Allowed values: 2008-R2-SP1, 2012-Datacenter, 2012-R2-Datacenter."
}
},
"vmCount": {
"type": "int",
"defaultValue": 1
},
"virtualNetworkName": {
"type": "string"
},
"dataDiskCount": {
"type": "int",
"defaultValue": 1
},
"recoveryVault": {
"type": "string",
"metadata": {
"description": "Backup vault name"
}
},
"recoveryPolicy": {
"type": "string",
"metadata": {
"description": "Backcup policy name"
}
},
"vmPrefix": {
"type": "string",
"metadata": {
"description": "Prefix for VM names, used with vmCount to build the VM names"
}
},
"vmRsg": {
"type": "string",
"metadata": {
"description": "Resource group where VMs reside"
}
}
},
"variables": {
"imagePublisher": "MicrosoftWindowsServer",
"imageOffer": "WindowsServer",
"OSDiskName": "osdiskforwindowssimple",
"nicName": "myVMNic",
"subnetName": "Subnet",
"vhdStorageType": "Standard_LRS",
"publicIPAddressName": "myPublicIP",
"publicIPAddressType": "Dynamic",
"vhdStorageContainerName": "vhds",
"vmName": "MWindowsVM",
"vmSize": "Standard_A2",
"virtualNetworkName": "MyVNET",
"vnetId": "[resourceId(resourceGroup().name, 'Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]",
"subnetRef": "[concat(variables('vnetId'), '/subnets/', variables('subnetName'))]"
},
"resources": [
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/publicIPAddresses",
"name": "[concat(variables('publicIPAddressName'), copyIndex(1))]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "PublicIPAddress"
},
"properties": {
"publicIPAllocationMethod": "[variables('publicIPAddressType')]",
"dnsSettings": {
"domainNameLabel": "[concat(parameters('dnsNameForPublicIP'), copyIndex(1))]"
}
},
"copy": {
"name": "publicIpCopy",
"count": "[parameters('vmCount')]"
}
},
{
"apiVersion": "2016-03-30",
"type": "Microsoft.Network/networkInterfaces",
"name": "[concat(variables('nicName'), copyIndex(1))]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "NetworkInterface"
},
"dependsOn": [
"[concat('Microsoft.Network/publicIPAddresses/', concat(variables('publicIPAddressName'), copyIndex(1)))]"
],
"properties": {
"ipConfigurations": [
{
"name": "[concat('ipconfig', copyIndex(1))]",
"properties": {
"privateIPAllocationMethod": "Dynamic",
"publicIPAddress": {
"id": "[resourceId('Microsoft.Network/publicIPAddresses', concat(variables('publicIPAddressName'), copyIndex(1)))]"
},
"subnet": {
"id": "[variables('subnetRef')]"
}
}
}
]
},
"copy": {
"name": "nicCopy",
"count": "[parameters('vmCount')]"
}
},
{
"apiVersion": "2017-03-30",
"copy": {
"name": "nodeCopy",
"count": "[parameters('vmCount')]"
},
"type": "Microsoft.Compute/virtualMachines",
"name": "[concat(variables('vmName'), copyIndex(1))]",
"location": "[resourceGroup().location]",
"tags": {
"displayName": "VirtualMachine"
},
"dependsOn": [
"[resourceId('Microsoft.Network/networkInterfaces/', concat(variables('nicName'), copyIndex(1)))]"
],
"properties": {
"hardwareProfile": {
"vmSize": "[variables('vmSize')]"
},
"osProfile": {
"computerName": "[concat(variables('vmName'), copyIndex(1))]",
"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"
},
"storageProfile": {
"imageReference": {
"publisher": "[variables('imagePublisher')]",
"offer": "[variables('imageOffer')]",
"sku": "[parameters('windowsOSVersion')]",
"version": "latest"
},
"osDisk": {
"createOption": "FromImage"
},
"copy": [
{
"name": "dataDisks",
"count": "[parameters('dataDiskCount')]",
"input": {
"diskSizeGB": 1023,
"lun": "[copyIndex('dataDisks')]",
"createOption": "Empty"
}
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "[resourceId('Microsoft.Network/networkInterfaces', concat(variables('nicName'), copyIndex(1)))]"
}
]
}
}
},
{
"apiVersion": "2017-05-10",
"name": "nestedTemplate",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "Env1",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', concat(variables('vmName'), copyIndex(1)))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"copy": {
"name": "protectedItemsCopy",
"count": "[parameters('vmCount')]"
},
"apiVersion": "2017-03-30",
"name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', parameters('vmPrefix'), copyIndex(1), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', parameters('vmPrefix'), copyIndex(1))]",
"location": "[resourceGroup().location]",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"properties": {
"protectedItemType": "Microsoft.Compute/virtualMachines",
"policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
"sourceResourceId": "[resourceId(subscription().subscriptionId ,parameters('vmRsg'),'Microsoft.Compute/virtualMachines', concat(parameters('vmPrefix'), copyIndex(1)) )]"
}
}
]
}
}
}
]
}
遗憾的是,它在尝试部署时报告了一个错误,我无法弄清楚为什么,因为它似乎是正确的。
Error: Code=InvalidTemplate; Message=Deployment template validation failed: 'The template resource 'nestedTemplate' at line '198' and column '10' is not valid: The template function 'copyIndex' is not expected at this location. The function can only be used in a resource with copy specified. Please see https://aka.ms/arm-copy for usage details.. Please see https://aka.ms/arm-template-expressions for usage details.'.
The deployment validation failed
仅供引用,第 198 行是 "name": "nestedTemplate",
请问有什么想法吗?
最佳答案
为了扩展@4c74356b41答案,我错过了所有重要的"index":{ "value": "[copyIndex()]"
"Microsoft.Resources/deployments"
内在父模板上。
对于那些想了解更多信息的人,请查看:https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-multiple
确保您拥有 ('index')
需要复制的项目旁边的参数,例如 "[concat(parameters('WHATEVER'), parameters('index'))]"
我最终还在链接模板中找到了一个嵌套源代码,用于我正在寻找的整体设计。
所以我的父模板有一个链接(子)模板(到另一个文件):
name": "[concat('nestings', copyIndex(1))]",
"type": "Microsoft.Resources/deployments", ...
我的子模板具有 VM 的所有常用结构,参数为 ('index')
以确保重复的项目命名正确。
最后,在子模板的底部,我有一个嵌套模板源,这样我就可以将虚拟机备份到另一个资源组(必须嵌套,否则无法执行多个资源组),如下所示:
{
"apiVersion": "2017-05-10",
"name": "[concat('nestedTemplate', parameters('index'))]",
"type": "Microsoft.Resources/deployments",
"resourceGroup": "Env1",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', concat(variables('vmName'), parameters('index')))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"apiVersion": "2016-06-01",
"name": "[concat( parameters('recoveryVault'), '/Azure/', 'iaasvmcontainer;iaasvmcontainerv2;', parameters('vmRsg') , ';', concat(parameters('vmPrefix'), parameters('index')), '/vm;iaasvmcontainerv2;', parameters('vmRsg'),';', concat(parameters('vmPrefix'), parameters('index')))]",
"location": "[resourceGroup().location]",
"type": "Microsoft.RecoveryServices/vaults/backupFabrics/protectionContainers/protectedItems",
"properties": {
"protectedItemType": "Microsoft.Compute/virtualMachines",
"policyId": "[resourceId('Microsoft.RecoveryServices/vaults/backupPolicies', parameters('recoveryVault'), parameters('recoveryPolicy'))]",
"sourceResourceId": "[resourceId(subscription().subscriptionId, parameters('vmRsg'), 'Microsoft.Compute/virtualMachines', concat(parameters('vmPrefix'), parameters('index')))]"
}
}
]
}
}
}
关于azure - ARM - 将多个虚拟机添加到恢复服务保管库 (copyIndex),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47397625/
我一直在尝试弄清VMware是如何工作的(特别是在安装Linux时),我有两个问题: 当VMware遇到push cs这样的命令时会发生什么?特别是cs,因为其特权级别为0,而VMware以1特权级别
我正在尝试将 vim 配置为我的主要编码程序。我已经想出了如何编译单个文件,但是当我从 vim 中执行程序时,我不断收到 127 错误代码。我的盒子上有 a 别名为 ./a.out,但是当我从 vim
我正在尝试将 vim 配置为我的主要编码程序。我已经想出了如何编译单个文件,但是当我从 vim 中执行程序时,我不断收到 127 错误代码。我的盒子上有 a 别名为 ./a.out,但是当我从 vim
想知道有没有什么javascript虚拟机是你用过的或者有什么想法的! 我不是在谈论用于 chrome 的 V8 等浏览器的 javascript 引擎,我想在 linux 服务器机器上执行 java
关闭。这个问题是off-topic .它目前不接受答案。 想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。 10年前关闭。 Improve this qu
我正在查找 Azure 中存储帐户的用途。因为我有一个问题。 我的帐户仅限于 1 个存储帐户,显然我已经在使用它,但我不知道为什么,我认为我不需要它。 我有一台带有云服务和存储帐户的虚拟机。我想创建另
Error - JVM - BlackBerry 9800 Simulator --------------------------------------- JVM: could not open
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 9
这是我的情况 我需要配置linux系统,因为路由器和客户端也在虚拟机中.. 系统A eth0:从isp获取ip(在VM ware中配置为Bidge) eth1: DEVICE=eth1 BOOTPRO
我知道 BEA 正在开发不需要底层操作系统的 LiquidVM,但想知道开源社区中是否有人正在开发类似的东西。 理想情况下,我想找到一个实现,其中 VM 直接由操作系统引导加载程序加载。 最佳答案 与
Linux系统下安装Vmware教程 由于项目需要,要在Linux下虚拟一个Windows,经过查找些资料,发现可一用VMware来实现,当然还有其他一些虚拟机可以使用如Win4lin,bochs
我正在使用虚拟机进行开发,但是每次我需要一个新的 VM 时,我都会复制文件并创建一个新服务器,但是我需要一个新的服务器名称才能将其添加到我们的网络中。 重命名服务器后,Sharepoint 站点有很多
如果 Cassandra 和代码在同一台机器上,则以下代码有效: using System; using Cassandra; namespace CassandraInsertTest {
关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。 想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?将问题更新为 on-topic对于堆栈溢出。 3年前关闭。 Improve this qu
我正在将我的 Web 应用程序 try catch 异常错误跟踪消息转储到 Web 服务器上的 C:\Temp 文件夹但是当我的 web 应用程序位于 azure 上时,我希望在 azure VM c
我们为客户提供桌面 ERP 软件。该软件安装在 Azure 虚拟机中。每个公司都有自己的数据库文件。我需要优化性能,但我有些怀疑无法找到回应。例如,对于 2 个公司: 1-购买 2 台小型 VM(2
我试图将 Azure 上的虚拟机的网络号地址更改为与 Azure 池上的另一个虚拟机位于同一网络中,一旦我单击网卡上的“保存”,它就会卡住并无法通过远程桌面或任何其他方式。 请帮忙。 最佳答案 切勿尝
是否可以在 Azure 上设置虚拟机并使该虚拟机的同一实例对多个用户可见? 我们是 ISV。我们的用户分散在全局。我们希望使用 Azure 虚拟机来指导用户设置我们的软件。理想情况下,我们的帮助台将在
我使用 Ubuntu 镜像创建了一个虚拟机,并从 Azure 库预加载了 Discourse。自动设置完成后,我可以看到虚拟机正在运行,但我无法连接到它以远程查看计算机。我没有看到任何设置可以为我解决
我是一名优秀的程序员,十分优秀!