0

以下のテンプレートから、既存の可用性セット (同じリソース グループ) に追加する方法を教えてください。VM の作成後はこれを行うことができないため、ここで行う必要があります。

エラーを取得する

可用性セット '/subscriptions/XXXXXXXXXXX/resourceGroups/XXXXXXXXXXXX/providers/Microsoft.Compute/availabilitySets/XXXXXXX' が見つかりません。

ただし、ポータルで利用できます。VM を手動でデプロイできます。

{
    "contentVersion": "1.0.0.0",
    "parameters": {
        SOME MORE PARAMETERS
        "AvSet":{
            "type": "string",
            "defaultValue": "XXXXXXXXXXXXX"
        },

    },
    "variables": {
        "ExtensionLink": "[concat(parameters('containerUrl'),'/domainjoin_extension.json')]",
        "subnetRef": "[resourceId(parameters('existingVnetResourceGroup'), 'Microsoft.Network/virtualNetworks/subnets', parameters('existingVnetName'),  parameters('existingSubnetName'))]",

    },
    "resources": [{
            "type": "Microsoft.Compute/virtualMachines",
            "name": "[parameters('virtualMachineName')]",
            "apiVersion": "2017-03-30",
            "location": "[resourceGroup().location]",
            "tags": "[parameters('tagValues')]",
            "properties": {
                "osProfile": {
                    "computerName": "[parameters('virtualMachineName')]",
                    "adminUsername": "[parameters('adminUsername')]",
                    "adminPassword": "[parameters('adminPassword')]"
                },
                "hardwareProfile": {
                    "vmSize": "[parameters('virtualMachineSize')]"
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "[parameters('publisher')]",
                        "offer": "[parameters('offer')]",
                        "sku": "[parameters('OSVersion')]",
                        "version": "latest"
                    },
                    "osDisk": {
                        "createOption": "fromImage",
                        "diskSizeGB": "[parameters('diskSizeGB')]",
                        "managedDisk": {
                            "storageAccountType": "[parameters('storageAccountType')]"
                        },
                        "name": "[parameters('osDiskName')]"
                    }

                },
                "networkProfile": {
                    "networkInterfaces": [{
                        "id": "[resourceId('Microsoft.Network/networkInterfaces', parameters('networkInterfaceName'))]"
                    }]
                },

                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "[reference(resourceId(parameters('existingStorageRgName'), 'Microsoft.Storage/storageAccounts', parameters('existingDiagnosticsStorageAccountName')), '2015-06-15').primaryEndpoints['blob']]"
                    }
                },
                "AvailabilitySet" : {
                  "id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('AvSet'))]"
                },
            },

            "dependsOn": [
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]",

            ]
        },

        {
            "type": "Microsoft.Network/networkInterfaces",
            "name": "[parameters('networkInterfaceName')]",
            "apiVersion": "2016-09-01",
            "location": "[resourceGroup().location]",
            "tags": "[parameters('tagValues')]",
            "properties": {

                "ipConfigurations": [{
                    "name": "ipconfig1",
                    "properties": {
                        "subnet": {
                            "id": "[variables('subnetRef')]"
                        },
                        "privateIPAllocationMethod": "Dynamic"
                    }
                }]
            }
        },
        {
            "apiVersion": "2017-05-10",
            "name": "linked1",
            "condition": "[equals(parameters('extensionCreateorNot'),'yes')]",
            "type": "Microsoft.Resources/deployments",
            "properties": {
                "mode": "incremental",
                "templateLink": {
                    "uri": "[variables('ExtensionLink')]",
                    "contentVersion": "1.0.0.0"
                },
                "parameters": {
                    "virtualMachineName": {
                        "value": "[string(parameters('virtualMachineName'))]"
                    },
                    "domainJoinUserName": {
                        "value": "[string(parameters('domainJoinUserName'))]"
                    },
                    "domainJoinUserPassword": {
                        "value": "[string(parameters('domainJoinUserPassword'))]"
                    },
                    "domainFQDN": {
                        "value": "[string(parameters('domainFQDN'))]"
                    },
                    "ouPath": {
                        "value": "[string(parameters('ouPath'))]"
                    }

                }

            },
            "dependsOn": [
                "linked2",
                "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]",
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"

            ]
        },
        {
            "apiVersion": "2017-05-10",
            "name": "linked2",
            "condition": "[equals(parameters('dataDisksattachornot'),'yes')]",
            "type": "Microsoft.Resources/deployments",
            "properties": {
                "mode": "incremental",
                "templateLink": {
                    "uri": "[variables('attachDataDiskExtensionLink')]",
                    "contentVersion": "1.0.0.0"
                },
                "parameters": {
                    "virtualMachineName": {
                        "value": "[string(parameters('virtualMachineName'))]"
                    },
                    "sizeOfDataDisksInGB": {
                        "value": "[array(parameters('sizeOfDataDisksInGB'))]"
                    },
                    "tagValues": {
                        "value": "[parameters('tagValues')]"
                    }
                }
            },
            "dependsOn": [
                "[concat('Microsoft.Compute/virtualMachines/', parameters('virtualMachineName'))]",
                "[concat('Microsoft.Network/networkInterfaces/', parameters('networkInterfaceName'))]"
            ]
        }
    ],
    "outputs": {
        "adminUsername": {
            "type": "String",
            "value": "[parameters('adminUsername')]"
        },
        "virtualMachineName": {
            "type": "String",
            "value": "[parameters('virtualMachineName')]"
        },
        "networkInterface": {
            "type": "string",
            "value": "[reference(concat(parameters('networkInterfaceName'))).ipConfigurations[0].properties.privateIPAddress]"
        }
    }
}
4

1 に答える 1