Azure ARM 模板“找不到带有名称的托管环境

Posted

技术标签:

【中文标题】Azure ARM 模板“找不到带有名称的托管环境【英文标题】:Azure ARM Template "Cannot find hostingEnvironment with name 【发布时间】:2017-07-31 09:15:14 【问题描述】:

我尝试部署 App 服务环境 v2 的 ARM 模板,我从官方 Azure GitHub 存储库 https://github.com/Azure/azure-quickstart-templates/tree/master/201-web-app-asp-app-on-asev2-create 获取。

当我启动它时,它会失败并显示“找不到带有名称的托管环境”。

【问题讨论】:

【参考方案1】:

您共享的模板不会为您创建 ASE。通过单击编辑模板链接,我发现它只创建了 2 个 Azure 资源。一个是 Azure Web App Plan,另一个是 Azure Web App。

要获取创建 ASE v2 的 ARM 模板,您可以在 Azure 门户上执行创建操作。输入必填字段后,点击自动化选项生成ARM模板。

这是我这边生成的示例 ARM 模板。


    "parameters": 
        "vnetName": 
            "type": "string"
        ,
        "vnetId": 
            "type": "string"
        ,
        "location": 
            "type": "string"
        ,
        "locationId": 
            "type": "string"
        ,
        "subnetName": 
            "type": "string"
        ,
        "VNetResourceGroupName": 
            "type": "string"
        ,
        "subnetAddress": 
            "type": "string"
        ,
        "vnetAddress": 
            "type": "string"
        ,
        "subnetRouteTableName": 
            "type": "string"
        ,
        "subnetNSGName": 
            "type": "string"
        ,
        "name": 
            "type": "string"
        ,
        "kind": 
            "type": "string"
        ,
        "subscriptionId": 
            "type": "string"
        
    ,
    "resources": [
        
            "name": "[parameters('name')]",
            "type": "Microsoft.Web/hostingEnvironments",
            "properties": 
                "name": "[parameters('name')]",
                "location": "[parameters('location')]",
                "VirtualNetwork": 
                    "Id": "[parameters('vnetId')]",
                    "type": "Microsoft.Network/virtualNetworks",
                    "Subnet": "[parameters('subnetName')]"
                
            ,
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/virtualNetworks/', parameters('vnetName'))]"
            ],
            "apiVersion": "2015-02-01",
            "kind": "[parameters('kind')]"
        ,
        
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/routeTables",
            "name": "[parameters('subnetRouteTableName')]",
            "location": "[parameters('location')]",
            "tags": 
                "displayName": "UDR - Subnet"
            ,
            "properties": 
                "routes": [
                    
                        "name": "myase-route",
                        "properties": 
                            "addressPrefix": "0.0.0.0/0",
                            "nextHopType": "Internet"
                        
                    
                ]
            
        ,
        
            "apiVersion": "2015-06-15",
            "type": "Microsoft.Network/networkSecurityGroups",
            "name": "[parameters('subnetNSGName')]",
            "location": "[parameters('location')]",
            "tags": 
                "displayName": "NSG - Subnet"
            ,
            "properties": 
                "securityRules": [
                    
                        "name": "Inbound-management",
                        "properties": 
                            "description": "Used to manage ASE from public VIP",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "454-455",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 100,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "ASE-internal-inbound",
                        "properties": 
                            "description": "ASE-internal-inbound",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "*",
                            "sourceAddressPrefix": "192.168.250.0/24",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 110,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Inbound-HTTP",
                        "properties": 
                            "description": "Allow HTTP",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "80",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 120,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Inbount-HTTPS",
                        "properties": 
                            "description": "Allow HTTPS",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "443",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 130,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Inbound-FTP",
                        "properties": 
                            "description": "Allow FTP over port 21",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "21",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 140,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Inbound-FTPS",
                        "properties": 
                            "description": "Allow FTPS",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "990",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 150,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Inbound-FTP-Data",
                        "properties": 
                            "description": "RDP",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "10001-10020",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 160,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Inbound-Remote-Debugging",
                        "properties": 
                            "description": "Visual Studio remote debugging",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "4016-4022",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 170,
                            "direction": "Inbound"
                        
                    ,
                    
                        "name": "Outbound-443",
                        "properties": 
                            "description": "Azure Storage blob",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "443",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 100,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "Outbound-SMB",
                        "properties": 
                            "description": "Azure Storage queue",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "445",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 110,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "Outbound-DB",
                        "properties": 
                            "description": "Database",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "1433",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 120,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "Outbound-DB2",
                        "properties": 
                            "description": "Database 2",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "11000-11999",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 130,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "Outbound-DB3",
                        "properties": 
                            "description": "Database 3",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "14000-14999",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 140,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "Outbound-DNS",
                        "properties": 
                            "description": "DNS",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "53",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 150,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "ASE-internal-outbound",
                        "properties": 
                            "description": "Azure Storage queue",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "*",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "192.168.250.0/24",
                            "access": "Allow",
                            "priority": 160,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "Outbound-80",
                        "properties": 
                            "description": "Outbound 80",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "80",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "*",
                            "access": "Allow",
                            "priority": 170,
                            "direction": "Outbound"
                        
                    ,
                    
                        "name": "ASE-to-VNET",
                        "properties": 
                            "description": "ASE to VNET",
                            "protocol": "*",
                            "sourcePortRange": "*",
                            "destinationPortRange": "*",
                            "sourceAddressPrefix": "*",
                            "destinationAddressPrefix": "192.168.250.0/23",
                            "access": "Allow",
                            "priority": 180,
                            "direction": "Outbound"
                        
                    
                ]
            
        ,
        
            "apiVersion": "2016-06-01",
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[parameters('vnetName')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[concat('Microsoft.Network/networkSecurityGroups/', parameters('subnetNSGName'))]",
                "[concat('Microsoft.Network/routeTables/', parameters('subnetRouteTableName'))]"
            ],
            "properties": 
                "addressSpace": 
                    "addressPrefixes": [
                        "[parameters('vnetAddress')]"
                    ]
                ,
                "subnets": [
                    
                        "name": "[parameters('subnetName')]",
                        "properties": 
                            "addressPrefix": "[parameters('subnetAddress')]",
                            "networkSecurityGroup": 
                                "id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('subnetNSGName'))]"
                            ,
                            "routeTable": 
                                "id": "[resourceId('Microsoft.Network/routeTables', parameters('subnetRouteTableName'))]"
                            
                        
                    
                ]
            
        
    ],
    "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0"

【讨论】:

谢谢,我会调查的 我用 asev2 导出模板并尝试在新资源组中重新部署它并遇到问题:(【参考方案2】:

定价层被标记为字符串,但分配的默认值是 int,因此 ARM 模板在部署时不可用。

【讨论】:

以上是关于Azure ARM 模板“找不到带有名称的托管环境的主要内容,如果未能解决你的问题,请参考以下文章

json ARM模板与copyindex #arm #azure

使用 ARM 模板创建 Azure Databricks 令牌

在 ARM 模板中使用访问密钥检索在 Azure 容器上装载 Azure 文件共享

用于部署和禁用 Azure 流分析服务的 ARM 模板

使用 ARM 模板对 Azure 存储帐户容器设置合法保留

使用 ARM 模板问题的 Azure 仪表板部署