简体   繁体   English

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

[英]Deploy Azure VM , ARM template with basic software

I am trying to create Azure VM with ARM template with basic software, I've written ARM template for this but I am unable to deploy VM in this template. 我正在尝试使用带有基本软件的ARM模板创建Azure VM,我已经为此编写了ARM模板,但是无法在此模板中部署VM。 Please refer below error :- 请参考以下错误:-

{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.","details":[{"code":"BadRequest","message":"{\\r\\n \\"error\\": {\\r\\n \\"code\\": \\"InvalidTemplate\\",\\r\\n \\"message\\": \\"Unable to process template language expressions for resource '/subscriptions/b312b990-e271-4a63-a63a-d6768e1c7aad/resourceGroups/rohittestrg/providers/Microsoft.Compute/virtualMachines/mydevboxvm1' at line '110' and column '9'. {“代码”:“ DeploymentFailed”,“消息”:“至少一项资源部署操作失败。请列出部署操作以获取详细信息。请参阅https://aka.ms/arm-debug以获取使用详细信息。”,“详细信息“:[{” code“:” BadRequest“,” message“:” {\\ r \\ n \\“ error \\”:{\\ r \\ n \\“ code \\”:\\“ InvalidTemplate \\”,\\ r \\ n \\ “ message \\”:\\“无法在'110'行和列处为资源'/subscriptions/b312b990-e271-4a63-a63a-d6768e1c7aad/resourceGroups/rohittestrg/providers/Microsoft.Compute/virtualMachines/mydevboxvm1'处理模板语言表达式'9'。 'The template parameter ' ' is not found. 找不到“模板参数”。 Please see https://aka.ms/arm-template/#parameters for usage details.'\\"\\r\\n }\\r\\n}"}]}. 有关用法的详细信息,请参见https://aka.ms/arm-template/#parameters。'\\"\\r\\n } \\ r \\ n}“}]}。

I used this link for reference https://raw.githubusercontent.com/FBoucher/SimpleDevBox/master/azure-deploy.json 我使用此链接作为参考https://raw.githubusercontent.com/FBoucher/SimpleDevBox/master/azure-deploy.json

Powershell script: Powershell脚本:

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

I am trying to do this on Windows server. 我正在尝试在Windows服务器上执行此操作。

This would be great if you can provide solution for this. 如果您可以为此提供解决方案,那就太好了。

{
    "$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": {}
}

You forgot to pass parameter names here: 您忘记在此处传递参数名称:

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

this should be this: 应该是这样的:

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

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM