我使用 Bicep 创建了一个 Azure Functions,其中使用的应用服务计划是之前在另一个订阅中创建的。
我收到以下错误:
{"status":"Failed","error":{"code":"DeploymentFailed","message":"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.","details":[{"code":"NotFound","message":"{\r\n \"Code\": \"NotFound\",\r\n \"Message\": \"Cannot find ServerFarm with name asp-intsharedep-prod.\",\r\n \"Target\": null,\r\n \"Details\": [\r\n {\r\n \"Message\": \"Cannot find ServerFarm with name myasp.\"\r\n },\r\n {\r\n \"Code\": \"NotFound\"\r\n },\r\n {\r\n \"ErrorEntity\": {\r\n \"ExtendedCode\": \"51004\",\r\n \"MessageTemplate\": \"Cannot find {0} with name {1}.\",\r\n \"Parameters\": [\r\n \"ServerFarm\",\r\n \"myasp\"\r\n ],\r\n \"Code\": \"NotFound\",\r\n \"Message\": \"Cannot find ServerFarm with name myasp.\"\r\n }\r\n }\r\n ],\r\n \"Innererror\": null\r\n}"}]}}
这只是一个简单的二头肌文件,没有模块,没有targetScope。我通过以下方式引用我的应用服务计划:
resource serverFarm 'Microsoft.Web/serverfarms@2020-06-01' existing = {
name: aspName
scope: resourceGroup('subscriptionid','rg-shared-asp')
}
是否无法在其他订阅中引用应用服务计划?
最佳答案
默认目标范围是资源组。因此,如果您不指定目标范围,则会隐式设置资源组范围。可用范围包括资源组、订阅、管理组和租户。因此,如果另一个订阅位于同一租户或管理组下,则可以将范围设置为其中一个。例如,在您的二头肌文件中注明:
targetScope = 'tenant'
在 az cli 上:
az deployment tenant create \
--name demoTenantDeployment \
--location WestUS \
--template-file main.bicep
关于azure-resource-manager - 如何使用 Bicep 引用其他订阅中的资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69946426/