azure - 资源组下的资源“Microsoft.Web/sites/abc-rg”' 没找到
问题描述
functionApp 已经部署成功。尝试使用带有 New-AzDeployment 的 Azure DevOps 内联 powershell 脚本来部署以下 ARM 模板时:
{
"$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#",
"contentVersion": "1.0.0.1",
"parameters": {
"location": {
"type": "string",
"defaultValue": "westus2",
"metadata": {
"description": "The region where resources are deployed"
}
},
"functionAppName": {
"type": "string",
"defaultValue": "event-driven-func2",
"metadata": {
"description": "Func App"
}
},
"eventGridSubscriptionName": {
"type": "string",
"defaultValue": "eventSub1",
"metadata": {
"description": "Name of Event Grid Subscription"
}
},
"eventGridFunc":{
"type": "string",
"defaultValue": "VmAddedListener",
"metadata": {
"description" : "Function Name"
}
}
},
"variables": {
"functionUrl" : "[concat('https://', parameters('FunctionAppName'),'.azurewebsites.net/runtime/webhooks/eventgrid?functionName=', parameters('eventGridFunc'),'&code=')]"
},
"resources": [
{
"apiVersion": "2018-01-01",
"type": "Microsoft.EventGrid/eventSubscriptions",
"name": "[parameters('eventGridSubscriptionName')]",
"location": "[parameters('location')]",
"properties": {
"destination": {
"endpointType": "Webhook",
"properties": {
"endpointUrl": "[concat(variables('functionUrl'), listKeys(resourceId('Microsoft.Web/sites/host/', parameters('functionAppName'), 'default'),'2016-08-01').masterKey)]"
}
},
"filter": {
"subjectBeginsWith": "",
"subjectEndsWith": "",
"isSubjectCaseSensitive": false,
"includedEventTypes": [
"Microsoft.Resources.ResourceActionCancel",
"Microsoft.Resources.ResourceActionFailure",
"Microsoft.Resources.ResourceActionSuccess",
"Microsoft.Resources.ResourceDeleteCancel",
"Microsoft.Resources.ResourceDeleteFailure",
"Microsoft.Resources.ResourceDeleteSuccess",
"Microsoft.Resources.ResourceWriteCancel",
"Microsoft.Resources.ResourceWriteFailure",
"Microsoft.Resources.ResourceWriteSuccess"
]
}
}
}
],
"outputs": {}
}
在发布期间收到以下错误:
“错误”:{“代码”:“ResourceNotFound”,“消息”:“未找到资源组''下的资源'Microsoft.Web/sites/abc-rg'。” } '
我是否需要在 ARM 中的某个位置指定资源组?
解决方案
您正在声明对 ARM 模板中未定义的资源的引用:listKeys(resourceId('Microsoft.Web/sites/host/', parameters('functionAppName'), 'default'),'2016-08-01').masterKey)]
resourceId
仅适用于 ARM 模板中定义的资源。您可以通过串联和一些附加参数来构建资源 ID,或者在同一个 ARM 模板中定义资源。
使用 ARM 模板时的理想状态是在单个模板(或全部由单个“主”模板引用的多个模板 )中定义整个环境,然后通过相应地更新模板来管理对环境的更改。
推荐阅读
- php - 将Foogallery插件更新到版本1.4.31后出现致命错误-在WordPress 4.9.8上运行
- postgresql - 日期范围内的天数
- php - PHP – 在 foreach 循环中对具有相同 ID 的输出进行分组
- javascript - 来自嵌套 for 循环的 TypeScript 中断开关/案例
- r - 结构()函数中的行名称
- vue.js - MiniCssExtractPlugin 无法在节点模块内加载 css 文件
- python - Python:在不使用循环的情况下查找二进制数据类型中每个 1 的索引的最快方法
- flask - flask apscheduler 启动一次但运行多次
- java - 如何解决MyBatis Pagination PageHelper 查询返回数据有重复?
- ios - 在 plist 字典中查找字符串