gpt4 book ai didi

azure - ARM模板: Resource Not Found Errors when grabbing outputs from Vault and Secrets

转载 作者:行者123 更新时间:2023-12-03 03:49:21 27 4
gpt4 key购买 nike

复制问题的示例模板(ID 已替换为“redacted-guid”):

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"rgName": {
"type": "string",
"defaultValue": "sample"
},
"vaultName": {
"type": "string",
"defaultValue": "TestVault333555"
}
},
"variables": {

},
"resources": [
{
"type": "Microsoft.Resources/resourceGroups",
"apiVersion": "2018-05-01",
"location": "West US",
"name": "[parameters('rgName')]",
"properties": {}
},
{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2017-05-10",
"name": "keyVaultsDeployment",
"resourceGroup": "[parameters('rgName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', parameters('rgName'))]"
],
"properties": {
"mode": "Incremental",
"template": {
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {},
"variables": {},
"resources": [
{
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2020-04-01-preview",
"name": "[parameters('vaultName')]",
"location": "westus",
"tags": {
"Environment": "Development",
"ResourceType": "Vaults"
},
"properties": {
"sku": {
"family": "A",
"name": "Standard"
},
"tenantId": "redacted-guid",
"accessPolicies": [
{
"tenantId": "redacted-guid",
"objectId": "redacted-guid",
"permissions": {
"keys": [
"Get"
],
"secrets": [
"Get"
],
"certificates": []
}
},
{
"tenantId": "redacted-guid",
"objectId": "redacted-guid",
"permissions": {
"keys": [
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"Backup",
"Restore"
],
"secrets": [
"Get",
"List",
"Set",
"Delete",
"Recover",
"Backup",
"Restore"
],
"certificates": [
"Get",
"List",
"Update",
"Create",
"Import",
"Delete",
"Recover",
"Backup",
"Restore",
"ManageContacts",
"ManageIssuers",
"GetIssuers",
"ListIssuers",
"SetIssuers",
"DeleteIssuers"
]
}
}
],
"enabledForDeployment": false,
"enabledForDiskEncryption": false,
"enabledForTemplateDeployment": false,
"enableSoftDelete": true,
"softDeleteRetentionInDays": 90,
"enableRbacAuthorization": false,
"enablePurgeProtection": true,
"provisioningState": "Succeeded"
}
},
{
"type": "Microsoft.KeyVault/vaults/secrets",
"apiVersion": "2020-04-01-preview",
"name": "[concat(parameters('vaultName'), '/SECRET')]",
"location": "westus",
"dependsOn": [
"[resourceId('Microsoft.KeyVault/vaults', parameters('vaultName'))]"
],
"properties": {
"attributes": {
"enabled": true
},
"value": "redacted-guid"
}
}
],
"outputs": {
"secret": {
"type": "string",
"value": "[reference(resourceId('Microsoft.KeyVault/vaults/secrets', parameters('vaultName'), 'SECRET'), '2017-05-10', 'Full').secretUri]"
},
"vaultLocation": {
"type": "string",
"value": "[reference(resourceId('Microsoft.KeyVault/vaults', parameters('vaultName')), '2017-05-10', 'Full').location]"
}
}
}
}
}
],
"outputs": {

}
}

错误:

2021-05-11T20:54:39.6696772Z ##[error]NotFound: {
"error": {
"code": "ResourceNotFound",
"message": "The Resource 'Microsoft.KeyVault/vaults/TestVault333555' under resource group '<null>'
was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
}
}
2021-05-11T20:54:39.6698437Z ##[error]NotFound: {
"error": {
"code": "ParentResourceNotFound",
"message": "Can not perform requested operation on nested resource. Parent resource 'TestVault333555'
not found."
}
}

我尝试了输出语法的多种变体,并尝试了其他输出数组,但一无所获。

在 DevOps 中,在发布管道下的“ARM 模板部署”作业中,我已将部署范围设置为“订阅”,因为我正在尝试创建参数化资源组并在该新资源组下部署 Vaults/Secrets资源组。据我了解,这就是我想要的,因为在 DevOps 中,如果我将部署范围设置为“资源组”,它需要我实际指定管道中的资源组,这不是我想要的,因为我想创建一个新的资源组。

任何有关克服这些错误的帮助或建议将不胜感激。总的来说,我对 ARM 还比较陌生。据我了解,我应该能够从 Azure 中的“JSON View ”中显示的资源中输出任何数据,对吗?

我主要寻找 3 条信息:

  • 保管库名称(这很简单,我可以将保管库名称参数作为输出输出,这不会给出错误)
  • secret 名称(在本例中: secret )
  • secret URI(下面尝试过)

最佳答案

刚刚回答了您关于同一问题的最后一个问题。如this链接描述了当您未在部署资源中设置 expressionEvaluationOptions' 属性时,您无法在输出部分中使用 reference() 函数。未设置时默认值为“outer”。

因此有 2 个选项:在父模板中声明您的输出,或将 expressionEvaluationOptions'-property 设置为“inner”并从那里开始

{
"type": "Microsoft.Resources/deployments",
"apiVersion": "2021-04-01",
"name": "keyVaultsDeployment",
"resourceGroup": "[parameters('rgName')]",
"dependsOn": [
"[resourceId('Microsoft.Resources/resourceGroups/', parameters('rgName'))]"
],
"properties": {"expressionEvaluationOptions": {
"scope": "inner"}

关于azure - ARM模板: Resource Not Found Errors when grabbing outputs from Vault and Secrets,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67505265/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com