gpt4 book ai didi

Azure KeyVaultAccessForbidden - "not enabled for deployment"

转载 作者:行者123 更新时间:2023-12-04 12:16:48 26 4
gpt4 key购买 nike

我正在构建一组脚本和模板来在 Azure 中创建 Service Fabric 群集。我有一个脚本可以创建 key 保管库和自签名证书并成功将其上传到保管库。另一个脚本创建集群,但在证书链接到虚拟机时遇到错误。 New-AzureRmResourceGroupDeployment 命令的错误是:-

{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "KeyVaultAccessForbidden",
"message": "Key Vault https://VAULT-NAME.vault.azure.net/secrets/clusterCert/SECRET-ID either has not been enabled for deployment or the vault id provided, /subscriptions/SUBSCRIPTION-ID/resourceGroups/jg-sf/providers/Microsoft.KeyVault/vaults/VAULTNAME, does not match the Key Vault's true resource id."
}
]
}

}

VAULT-NAME、SUBSCRIPTION-ID 和 SECRET-ID 均正确。已使用参数 "enabledForTemplateDeployment": true 创建 key 保管库,如以下屏幕截图所示。

Key vault config screenshot

我的脚本和模板可以在 GitHub 中看到 - https://github.com/goochjs/azure-testbed .

如何诊断问题?

谢谢

杰里米。

最佳答案

如何创建 key 保管库,我使用以下脚本创建 key 保管库并获取CertificateURL。

New-AzureRmKeyVault -VaultName $KeyVaultName -ResourceGroupName $ResourceGroup -Location $Location -sku standard -EnabledForDeployment 

#Creates a new selfsigned cert and exports a pfx cert to a directory on disk
$NewCert = New-SelfSignedCertificate -CertStoreLocation Cert:\CurrentUser\My -DnsName $CertDNSName
Export-PfxCertificate -FilePath $CertFileFullPath -Password $SecurePassword -Cert $NewCert
Import-PfxCertificate -FilePath $CertFileFullPath -Password $SecurePassword -CertStoreLocation Cert:\LocalMachine\My

#Reads the content of the certificate and converts it into a json format
$Bytes = [System.IO.File]::ReadAllBytes($CertFileFullPath)
$Base64 = [System.Convert]::ToBase64String($Bytes)

$JSONBlob = @{
data = $Base64
dataType = 'pfx'
password = $Password
} | ConvertTo-Json

$ContentBytes = [System.Text.Encoding]::UTF8.GetBytes($JSONBlob)
$Content = [System.Convert]::ToBase64String($ContentBytes)

#Converts the json content a secure string
$SecretValue = ConvertTo-SecureString -String $Content -AsPlainText -Force

#Creates a new secret in Azure Key Vault
$NewSecret = Set-AzureKeyVaultSecret -VaultName $KeyVaultName -Name $KeyVaultSecretName -SecretValue $SecretValue -Verbose

#Writes out the information you need for creating a secure cluster
Write-Host
Write-Host "Resource Id: "$(Get-AzureRmKeyVault -VaultName $KeyVaultName).ResourceId
Write-Host "Secret URL : "$NewSecret.Id
Write-Host "Thumbprint : "$NewCert.Thumbprint

更多相关信息,请引用这个blog .

我建议您检查您的Resource Id 格式。正确的格式类似于 /subscriptions/****************/resourceGroups/westus-mykeyvault/providers/Microsoft.KeyVault/vaults/shuisfsvault。您可以先在Azure Portal上创建SF集群。

如果仍然无法正常工作,我建议您可以检查您的 key 保管库,您是否授予了足够的权限?

enter image description here

注意:为了测试,您可以将所有权限授予用户。

关于Azure KeyVaultAccessForbidden - "not enabled for deployment",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47799311/

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