2016-04-25 134 views
0

我正在嘗試開發用於部署多個webapps的ARM模板,但我試圖使用Microsoft.Web/sites/config中的可用設置配置webapp。無論我放在那裏,當我部署webapp時,這些設置都會被忽略。我將我的模板放在David Ebbos example上。Azure忽略ARM模板中的網站配置設置

這就是我此刻想:

// Serverfarm (appservice) 
{ 
    "apiVersion": "2015-08-01", 
    "type": "Microsoft.Web/serverfarms", 
    "sku": { 
     "name": "B1", 
     "tier": "Standard", 
     "size": "B1", 
     "family": "B", 
     "capacity": 1 
    }, 
    "name": "[variables('appSvcName')]", 
    "location": "[resourceGroup().location]", 
    "tags": { 
     "project": "[[variables('webAppName')]]" 
    }, 
    "properties": { 
     "name": "[variables('appSvcName')]", 
     "numberOfWorkers": 1 
    } 
}, 
// Site (Webapp) 
{ 
    "apiVersion": "2015-08-01", 
    "type": "Microsoft.Web/sites", 
    "name": "[variables('webAppName')]", 
    "location": "[resourceGroup().location]", 
    "tags": { 
     "project": "[[variables('webAppName')]]" 
    }, 
    "dependsOn": [ 
     "[resourceId('Microsoft.Web/serverfarms', variables('appSvcName'))]" 
    ], 
    "properties": { 
     "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appSvcName'))]", 
     "hostNames": [ 
      "[concat(variables('webAppName'), '.azurewebsites.net')]" 
     ], 
     "enabledHostNames": [ 
      "[concat(variables('webAppName'), '.azurewebsites.net')]", 
      "[concat(variables('webAppName'), '.scm.azurewebsites.net')]" 
     ], 
     // TODO : These resources are ignored so far 
     "resources": [ 
      { 
       "apiVersion": "2015-08-01", 
       "name": "web", 
       "type": "Microsoft.Web/sites/config", 
       "location": "[resourceGroup().location]", 
       "dependsOn": [ 
        "[resourceId('Microsoft.Web/Sites', variables('webAppName'))]" 
       ], 
       "properties": { 
        "phpVersion": "", 
        "netFrameworkVersion": "v4.6", 
        "use32BitWorkerProcess": false, /* 64-bit platform */ 
        "webSocketsEnabled": true, 
        "alwaysOn": true, 
        "requestTracingEnabled": true, /* Failed request tracing, aka 'freb' */ 
        "httpLoggingEnabled": true, /* IIS logs (aka Web server logging) */ 
        "logsDirectorySizeLimit": 40, /* 40 MB limit for IIS logs */ 
        "detailedErrorLoggingEnabled": true, /* Detailed error messages */ 
        "remoteDebuggingEnabled": false, 
        "remoteDebuggingVersion": "VS2015", 
        "defaultDocuments": [ 
         "default.aspx", 
         "Default.htm", 
         "Default.html", 
         "index.html", 
         "hostingstart.html" 
        ] 
       } 
      }, 
      { 
       "apiVersion": "2015-08-01", 
       "name": "connectionstrings", 
       "type": "Microsoft.Web/sites/config", 
       "location": "[resourceGroup().location]", 
       "dependsOn": [ 
        "[resourceId('Microsoft.Web/Sites', variables('webAppName'))]" 
       ], 
       "properties": { 
        "umbracoDbDsn": { 
         "value": "[concat('Data Source=tcp:', reference(concat('Microsoft.Sql/servers/', variables('sqlServerName'))).fullyQualifiedDomainName, ',1433;Initial Catalog=', variables('sqlDbName'), ';User Id=', variables('appSvcName'), '@', variables('sqlServerName'), ';Password=e15cO1PtIR5dtq3zUlwK;')]", 
         "type": "SQLAzure" 
        } 
       } 
      } 
     ] 
    } 
} 

有一件事我有點困惑的是,當我在蔚藍的PowerShell控制檯運行(Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes沒有網站/配置ResourceTypeName可用。

什麼給?配置資源類型是否已從模板定義中刪除?我是否使用了錯誤的apiVersion?我嘗試了許多不同的組合,無濟於事。

+1

爲什麼你把「資源」放在「屬性」裏面?它應該在「屬性」之外並在您的Web應用程序下。 –

+0

我沒有注意到@JackZeng感謝您發現它。 – Hauge

回答

1

請參閱本博客 - http://wp.sjkp.dk/arm-templates-set-always-on-and-other-site-properties/

您需要在Web /配置的resource.properties siteConfig對象。

{ 
    "apiVersion": "2015-08-01", 
    "name": "[parameters('webSiteName')]", 
    "type": "Microsoft.Web/sites", 
    "location": "[resourceGroup().location]", 
    "tags": { 
     "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource", 
     "displayName": "Website" 
    }, 
    "dependsOn": [ 
     "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]" 
    ], 
    "properties": { 
     "name": "[parameters('webSiteName')]", 
     "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]" 
    }, 
    "resources": [ 
     { 
      "apiVersion": "2015-08-01", 
      "name": "web", 
      "type": "config", 
      "dependsOn": [ 
       "[concat('Microsoft.Web/sites/', parameters('webSiteName'))]" 
      ], 
      "properties": { 
       "javaVersion": "1.8", 
       "javaContainer": "TOMCAT", 
       "javaContainerVersion": "8.0", 
       "siteConfig": { 
        "<supported-property>": "<value>", 
       } 
      } 
     } 
    ] 
} 
0

模式中的錯誤,如@JackZheng所述。 Test-AzureRmResourceGroupDeployment命令也沒有報告這些錯誤,這使得查找和更正有點困難。