如何在ARM模板中引用已经存在的Azure Portal创建的存储帐户

我想用ARM模板创建一个功能应用程序,以便ARM模板引用已经参数化的现有存储帐户( inputstgdev outputstgdev )。我希望ARM模板使用 inputstgdev 存储帐户作为其附加存储帐户,这样就不必创建新的存储帐户。函数应用程序的源代码控制引用了Gitrepo,我也在ARM模板中对其进行了参数化。每次我运行ARM模板时,都会收到以下错误消息

## [错误]部署模板验证失败:“资源” /subscriptions/bea8ac84-24a4-4e53-9198-e3b0107547d4/resourceGroups/dev-rgp/providers/microsoft.Web/sites/第1行和第3069列中的functionapp / sourcecontrols / web不依赖于父资源'/subscriptions/bea8ac84-24a4-4e53-9198-e3b0107547d4/resourceGroups/dev-rgp/providers/microsoft.Web/sites / functionapp”。请使用'dependsOn'语法显式添加依赖项。请参阅aka.ms/arm-template/#resources

任何建议可能是什么问题或可能的解决方案。 期待您的答复

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion": "1.0.0.0","parameters": {
    "Inputstorageaccount": {
        "defaultvalue": "inputstgdev","type": "String"
    },"GitrepoBranch": {
       "type": "string","defaultvalue": "master","metadata": {
            "description": "Name of the branch to use when deploying (Default = master)."
        }
    },"GitrepoURL": {
       "type": "string","defaultvalue": "https://github.com/FBoucher/AzUnzipEverything.git","metadata": {
            "description": "URL to repo (Default = master)."
        }
    },"InputcontainerName": {
      "type": "string","defaultvalue": "inputcontainer","metadata": {
        "description": "Specifies the name of the blob container."
      }
    },"Outputstorageaccount": {
        "defaultvalue": "outputstgdev","OutputcontainerName": {
      "type": "string","defaultvalue": "outputcontainer","metadata": {
        "description": "Specifies the name of the blob container."
      }
    }
},"variables": {},"resources": [
    {
        "type": "microsoft.Storage/storageaccounts/blobServices/containers","apiVersion": "2019-06-01","name": "[concat(parameters('Inputstorageaccount'),'/default/',parameters('InputcontainerName'))]","properties": {
            "publicaccess": "None"
        }
    },{
        "type": "microsoft.Storage/storageaccounts/blobServices/containers","name": "[concat(parameters('Outputstorageaccount'),parameters('OutputcontainerName'))]",{
        "name": "serviceplan","type": "microsoft.Web/serverfarms","apiVersion": "2018-02-01","location": "[resourceGroup().location]","sku": {
            "name": "F1","capacity": 1
        },"tags": {
            "displayName": "serviceplan"
        },"properties": {
            "name": "serviceplan"
        }
    },{
        "name": "functionapp","type": "microsoft.Web/sites","apiVersion": "2018-11-01","kind": "functionapp","dependsOn": [
            "[resourceId('microsoft.Web/serverfarms','serviceplan')]","[resourceId('microsoft.Storage/storageaccounts',parameters('Inputstorageaccount'))]"
        ],"properties": {
            "serverFarmId": "[resourceId('microsoft.Web/serverfarms',"siteConfig": {
                "appSettings": [
                    {
                        "name": "AzureWebJobsDashboard","value": "[concat('DefaultEndpointsProtocol=https;accountName=',parameters('Inputstorageaccount'),';accountKey=',listKeys(parameters('InputcontainerName'),'2015-05-01-preview').key1)]"
                    },{
                        "name": "AzureWebJobsStorage",{
                        "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",{
                        "name": "WEBSITE_CONTENTSHARE","value": "[toLower('functionapp')]"
                    },{
                        "name": "FUNCTIONS_EXTENSION_VERSION","value": "~2"
                    },{
                        "name": "APPINSIGHTS_INSTRUMENTATIONKEY","value": "[reference(resourceId('microsoft.insights/components/','applicationInsightsname'),'2015-05-01').InstrumentationKey]"
                    },{
                        "name": "FUNCTIONS_WORKER_RUNTIME","value": "dotnet"
                    }
                ]
            }
        },"resources":[
            {
                "apiVersion": "2015-08-01","name": "web","type": "sourcecontrols","dependsOn": [
                  "[resourceId('microsoft.Web/sites/',parameters('Inputstorageaccount'))]"
                ],"properties": {
                    "RepoUrl": "[parameters('GitrepoURL')]","branch": "[parameters('GitrepoBranch')]","publishRunbook": true,"IsManualIntegration": true
                }
            }
        ]

    }
]

}

iCMS 回答:如何在ARM模板中引用已经存在的Azure Portal创建的存储帐户

由于错误的依赖性,您遇到了此错误消息。

您应该使用"[resourceId('Microsoft.Web/sites/','functionapp')]"而不是"[resourceId('Microsoft.Web/sites/',parameters('InputstorageAccount'))]"

并且您应该删除存储依赖项。

"[resourceId('Microsoft.Storage/storageAccounts',parameters('InputstorageAccount'))]"

顺便说一句,因为您已经有一个存储帐户,所以只需将连接字符串粘贴到 AzureWebJobsStorage AzureWebJobsDashboard 的值中。

就像

{
    "name": "AzureWebJobsDashboard","value": "{connectionstring}"
}
本文链接:https://www.f2er.com/2146111.html

大家都在问