2017-06-21 32 views
0

我已經創建了SQL Server和數據庫,Web應用程序,已發佈的網站和數據庫並進入網站的登錄屏幕。ARM模板 - 爲Web應用程序創建SQL Server防火牆規則

當我登錄時,我收到一個包含當前不允許訪問新創建的SQL Server的Web應用程序的IP地址的500。

我非常想收穫分配的IP地址(懷疑它是AZURE內部IP地址)以在模板中創建防火牆規則。

我成功地爲存儲帳戶密鑰和數據庫連接字符串添加應用設置。這些工作很好。

非常令人沮喪的是無法找到任何對網站內部IP的引用。我已經嘗試了Azure門戶中的對象瀏覽器。

意見建議謝謝! Andy

回答

0

如果您正在使用Azure SQL,關於如何設置Azure數據庫防火牆,請參閱document

非常令人沮喪的是,無法找到任何對網站內部IP的引用?

如果想讓Azure的服務來訪問SQL Azure的數據庫,我們只需要設置

允許訪問Azure服務上。的默認值爲

enter image description here

我們也能拿的出站IP地址,我們可以從蔚藍的資源(https://resources.azure.com/)讓他們再outboundIpAddresses添加到允許的IP列表中的SQL Azure的防火牆規則。

enter image description here

注意:對於Web應用程序天青的outboundIpAddresses不是靜態IP地址,當我們重新啓動Web應用程序或Web應用程序更改服務計劃,他們可以改變。

如果我們想通過ARM模板添加防火牆規則,我們可以使用下面的演示代碼:

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
     "testfirewallAdminLogin": { 
      "type": "string", 
      "minLength": 1 
     }, 
     "testfirewallAdminLoginPassword": { 
      "type": "securestring" 
     }}, 
    "variables": { 
     "testfirewallName": "[concat('testfirewall', uniqueString(resourceGroup().id))]"}, 
    "resources": [ 
     { 
      "name": "[variables('testfirewallName')]", 
      "type": "Microsoft.Sql/servers", 
      "location": "[resourceGroup().location]", 
      "apiVersion": "2014-04-01-preview", 
      "dependsOn": [ ], 
      "tags": { 
       "displayName": "testfirewall" 
      }, 
      "properties": { 
       "administratorLogin": "[parameters('testfirewallAdminLogin')]", 
       "administratorLoginPassword": "[parameters('testfirewallAdminLoginPassword')]" 
      }, 
      "resources": [ 
       { 
        "name": "AllowAllWindowsAzureIps", 
        "type": "firewallrules", 
        "location": "[resourceGroup().location]", 
        "apiVersion": "2014-04-01-preview", 
        "dependsOn": [ 
         "[resourceId('Microsoft.Sql/servers', variables('testfirewallName'))]" 
        ], 
       "properties": { 
        "startIpAddress": "x.x.x.x", 
        "endIpAddress": "x.x.x.x" 
       } 
       } 
      ] 
     }], 
    "outputs": { 

    } 
} 
相關問題