Ошибка ARM-шаблона для назначения публичного IP-адреса для виртуальной машины - PullRequest
0 голосов
/ 07 февраля 2019

Здравствуйте, у меня написан код JSON для развертывания виртуальной машины, но я получаю сообщение об ошибке при назначении общедоступного IP-адреса в конфигурации IP.Сообщение об ошибке Не удалось проверить шаблон развертывания: «Ресурс шаблона» [Параметры ('envPrefixName')] - NetworkInterface »в строке« 123 »и столбец« 9 »недопустим: невозможно проанализировать выражение языка« resourceId («Microsoft.Network/publicIPAddresses ',' [Parameters ('envPrefixName')] - PublicIP ')': ожидаемый токен 'RightParenthesis' и фактический 'Identifier' .. Подробную информацию об использовании см. в https://aka.ms/arm-template-expressions. '.(Код: InvalidTemplate)

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

    "envPrefixName": {
        "type": "string",
        "metadata": {
            "description": "Prefix for the environment (2-5 characters)"
        },
        "defaultValue": "cust1",
        "minLength": 2,
        "maxLength": 5
    }
},
"variables": {
   "scriptURL":" https://raw.githubusercontent.com/rt7055/simpledevbox1/master/simpledevbox.ps1 "
},
"resources": [
    {
        "type": "Microsoft.Storage/storageAccounts",
        "name": "[Parameters('envPrefixName')]-storagekata",
        "apiVersion": "2015-06-15",
        "location": "[resourceGroup().location]",
        "tags": {
            "displayName": "[Parameters('envPrefixName')] Storage Account"
        },
        "properties": {
            "accountType":"Standard_LRS"
        }
    },
    {
        "apiVersion": "2017-06-01",
        "type": "Microsoft.Network/publicIPAddresses",
        "name": "[Parameters('envPrefixName')]-PublicIP",
        "location": "[resourceGroup().location]",
        "properties":{
            "publicIPAllocationMethod":"Dynamic"
        },
        "tags": {
            "displayName": "PublicIPAddress"
        }
    },
         {
        "apiVersion": "2017-06-01",
        "type": "Microsoft.Network/virtualNetworks",
        "name": "[Parameters('envPrefixName')]-VirtualNetwork",
        "location": "[resourceGroup().location]",
        "tags": {
            "displayName": "VirtualNetwork"
        },
        "properties": {
            "addressSpace": {
                "addressPrefixes": [
                    "10.0.0.0/16"
                ]
            },
            "subnets": [
                {
                    "name": "[Parameters('envPrefixName')]-VirtualNetwork-Subnet",
                    "properties": {
                        "addressPrefix": "10.0.0.0/24"
                    }
                }
            ]
        }
    },
    {
        "apiVersion": "2017-06-01",
        "type": "Microsoft.Network/networkSecurityGroups",
        "name": "[Parameters('envPrefixName')]-securitygroup",
        "location": "[resourceGroup().location]",
        "tags": {
            "displayName": "FrontEndNSG"
        },
        "properties": {
            "securityRules": [
                {
                    "name": "rdp_rule",
                    "properties": {
                        "description": "Allow RDP",
                        "protocol": "Tcp",
                        "sourcePortRange": "*",
                        "destinationPortRange": "3389",
                        "sourceAddressPrefix": "Internet",
                        "destinationAddressPrefix": "*",
                        "access": "Allow",
                        "priority": 100,
                        "direction": "Inbound"
                    }
                }
              ]
            }
        },


    {
        "apiVersion": "2015-06-15",
        "type": "Microsoft.Network/networkInterfaces",
        "name": "[Parameters('envPrefixName')]-NetworkInterface",
        "location": "[resourceGroup().location]",
        "dependsOn": [
            "Microsoft.Network/publicIPAddresses/[Parameters('envPrefixName')]-PublicIP",
            "Microsoft.Network/virtualNetworks/[Parameters('envPrefixName')]-VirtualNetwork"
        ],
        "tags": {
            "displayName": "[Parameters('envPrefixName')] Network Interface"
        },
        "properties": {
            "ipConfigurations": [
                {
                    "name": "ipconfig1",
                    "properties": {
                        "privateIPAllocationMethod": "Dynamic",
                        "publicIPAddress": {
                            "id": "[resourceId('Microsoft.Network/publicIPAddresses', '[Parameters('envPrefixName')]-PublicIP')]"
                        },
                        "subnet": {
                            "id": "[concat(resourceId('Microsoft.Network/virtualNetworks', '[Parameters('envPrefixName')]-VirtualNetwork'), '/subnets/[Parameters('envPrefixName')]-VirtualNetwork-Subnet')]"
                        }
                    }
                }
            ]
        }
    },
                       {
        "apiVersion": "2017-03-30",
        "type": "Microsoft.Compute/virtualMachines",
        "name": "[Parameters('envPrefixName')]",
        "location": "[resourceGroup().location]",
        "dependsOn": [
            "[concat('Microsoft.Storage/storageAccounts/', toLower('[Parameters('envPrefixName')]storagekata'))]",
            "Microsoft.Network/networkInterfaces/[Parameters('envPrefixName')]-NetworkInterface"
        ],
        "tags": {
            "displayName": "[Parameters('envPrefixName')]"
        },
        "properties": {
            "hardwareProfile": {
                "vmSize":"Standard_A1"
            },
            "osProfile": {
                "computerName": "[Parameters('envPrefixName')]",
                "adminUsername": "[parameters('adminUsername')]",
                "adminPassword": "[parameters('adminPassword')]"
            },
            "storageProfile": {
                "imageReference": {
                    "publisher": "MicrosoftWindowsServer",
                    "offer": "WindowsServer",
                    "sku": "2012-R2-Datacenter",
                    "version": "latest"
                },
                "osDisk": {
                    "name": "[Parameters('envPrefixName')]OSDisk",
                    "createOption": "FromImage",
                    "caching": "ReadWrite"

                                    }                 
            },
            "networkProfile": {
                "networkInterfaces": [
                    {
                        "id": "[resourceId('Microsoft.Network/networkInterfaces', '[Parameters('envPrefixName')]-NetworkInterface')]"
                    }
                ]
            },
            "diagnosticsProfile": {
                "bootDiagnostics": {
                    "enabled": true,
                    "storageUri": "[concat('http://', toLower('[Parameters('envPrefixName')]storagekata'), '.blob.core.windows.net')]"
                }
            }
        },
        "resources": [
            {
                "apiVersion": "2017-03-30",
                "type": "extensions",
                "name": "config-app",
                "location": "[resourceGroup().location]",
                "dependsOn": [
                    "[concat('Microsoft.Compute/virtualMachines/', '[Parameters('envPrefixName')]vm1')]"
                ],
                "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": {}

}

должен принять публичный IP.

Кто-то может помочь мне решить эту проблему

...