使用基本软件部署Azure VM和ARM模板

时间:2019-02-05 16:29:47

标签: azure templates virtual-machine

我正在尝试使用具有基本软件的ARM模板创建Azure VM,我已经为此编写了ARM模板,但是无法在此模板中部署VM。 请参考以下错误:-

  

{“代码”:“ DeploymentFailed”,“消息”:“至少一项资源部署   手术失败。请列出部署操作以获取详细信息。   请参阅https://aka.ms/arm-debug以了解用法   详细信息。“,”详细信息“:[{”代码“:” BadRequest“,”消息“:” {\ r \ n \“错误\”:   {\ r \ n \“ code \”:\“ InvalidTemplate \”,\ r \ n \“ message \”:\“无法   处理资源的模板语言表达   '/subscriptions/b312b990-e271-4a63-a63a-d6768e1c7aad/resourceGroups/rohittestrg/providers/Microsoft.Compute/virtualMachines/mydevboxvm1'   在“ 110”行和“ 9”列。 '模板参数''不是   找到了。请参阅https://aka.ms/arm-template/#parameters以了解用法   详细信息。'\“ \ r \ n} \ r \ n}”}]}。

我将此链接用作参考     https://raw.githubusercontent.com/FBoucher/SimpleDevBox/master/azure-deploy.json

Powershell脚本:

https://raw.githubusercontent.com/rt7055/Testrepo/master/simpledevbox.ps1?token=AtI3tjSPO7YLVq2xI2zPwznWAZPiWzd2ks5cWbmOwA%3D%3D

我正在尝试在Windows服务器上执行此操作。

如果您可以为此提供解决方案,那就太好了。

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters":{
        "scriptURL": {
            "type":"string"

        },
        "adminUsername": {
            "type":"string"
        },
        "adminPassword": {
            "type":"string"
        }  
    },
    "variables": {
       "scriptURL":" https://raw.githubusercontent.com/rt7055/Testrepo/master/simpledevbox.ps1?token=AtI3to3qKSHYNEZh9tfMfXZQ-P4zRULeks5cWZ5kwA%3D%3D "
    },
    "resources": [
        {
            "type": "Microsoft.Storage/storageAccounts",
            "name": "[toLower('mydevboxstoragekata')]",
            "apiVersion": "2015-06-15",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "mydevbox Storage Account"
            },
            "properties": {
                "accountType":"Standard_LRS"
            }
        },
        {
            "apiVersion": "2017-06-01",
            "type": "Microsoft.Network/publicIPAddresses",
            "name": "mydevbox-PublicIP",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "PublicIPAddress"
            }

        },
        {
            "apiVersion": "2017-06-01",
            "type": "Microsoft.Network/virtualNetworks",
            "name": "mydevbox-VirtualNetwork",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "VirtualNetwork"
            },
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "10.0.0.0/16"
                    ]
                },
                "subnets": [
                    {
                        "name": "mydevbox-VirtualNetwork-Subnet",
                        "properties": {
                            "addressPrefix": "10.0.0.0/24"
                        }
                    }
                ]
            }
        },
        {
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/networkInterfaces",
            "name": "mydevbox-NetworkInterface",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "Microsoft.Network/publicIPAddresses/mydevbox-PublicIP",
                "Microsoft.Network/virtualNetworks/mydevbox-VirtualNetwork"
            ],
            "tags": {
                "displayName": "mydevbox Network Interface"
            },
            "properties": {
                "ipConfigurations": [
                    {
                        "name": "ipconfig1",
                        "properties": {
                            "privateIPAllocationMethod": "Dynamic",
                            "publicIPAddress": {
                                "id": "[resourceId('Microsoft.Network/publicIPAddresses', 'mydevbox-PublicIP')]"
                            },
                            "subnet": {
                                "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', 'mydevbox-VirtualNetwork'), '/subnets/mydevbox-VirtualNetwork-Subnet')]"
                            }
                        }
                    }
                ]
            }
        },
        {
            "apiVersion": "2017-03-30",
            "type": "Microsoft.Compute/virtualMachines",
            "name": "mydevboxvm1",
            "location": "[resourceGroup().location]",
            "dependsOn": [
                "[concat('Microsoft.Storage/storageAccounts/', toLower('mydevboxstoragekata'))]",
                "Microsoft.Network/networkInterfaces/mydevbox-NetworkInterface"
            ],
            "tags": {
                "displayName": "mydevboxvm1"
            },
            "properties": {
                "hardwareProfile": {
                    "vmSize": "Standard_A1"
                },
                "osProfile": {
                    "computerName": "mydevboxvm1",
                    "adminUsername": "[parameters('')]",
                    "adminPassword": "[parameters('')]"
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "MicrosoftWindowsServer",
                        "offer": "WindowsServer",
                        "sku": "2012-R2-Datacenter",
                        "version": "latest"
                    },
                    "osDisk": {
                        "createOption": "FromImage"
                                        },
                                        "dataDisks":[
                                            {
                                            "diskSizeGB": 1023,
                                             "lun": 0,
                                             "createOption": "Empty"}
                                        ]
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces', 'mydevbox-NetworkInterface')]"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "[concat('http://', toLower('mydevboxstoragekata'), '.blob.core.windows.net')]"
                    }
                }
            },
            "resources": [
                {
                    "apiVersion": "2017-03-30",
                    "type": "extensions",
                    "name": "config-app",
                    "location": "[resourceGroup().location]",
                    "dependsOn": [
                        "[concat('Microsoft.Compute/virtualMachines/', 'mydevboxvm1')]"
                    ],
                    "tags": {
                        "displayName": "config-app"
                    },
                    "properties": {
                        "publisher": "Microsoft.Compute",
                        "type": "CustomScriptExtension",
                        "typeHandlerVersion": "1.9",
                        "autoUpgradeMinorVersion": true,
                        "settings": {
                            "fileUris": [
                               "[variables('scriptURL')]"
                            ]
                        },
                        "protectedSettings": {
                            "commandToExecute": "[concat('powershell -ExecutionPolicy Unrestricted -File ', './simpledevbox.ps1')]"
                        }
                    }
                }
            ]
        }
    ],
    "outputs": {}
}

1 个答案:

答案 0 :(得分:0)

您忘记在此处传递参数名称:

"adminUsername": "[parameters('')]",
"adminPassword": "[parameters('')]"

应该是这样:

"adminUsername": "[parameters('adminUsername')]",
"adminPassword": "[parameters('adminPassword')]"

enter image description here