Jer*_*och 7 azure azure-resource-manager azure-service-fabric azure-keyvault azure-template
我正在构建一组脚本和模板以在Azure中创建Service Fabric群集。我有一个脚本,该脚本创建密钥库和自签名证书,并将其成功上传到库中。另一个脚本创建了群集,但是在证书链接到虚拟机时出现了错误。该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."
}
]
}
Run Code Online (Sandbox Code Playgroud)
}
VAULT-NAME,SUBSCRIPTION-ID和SECRET-ID均正确。密钥库已使用参数创建"enabledForTemplateDeployment": true
,如以下屏幕截图所示。
我的脚本和模板可以在GitHub- https://github.com/goochjs/azure-testbed中看到。
我如何诊断问题?
谢谢,
杰里米
如何创建密钥库,我使用以下脚本创建密钥库并获取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
Run Code Online (Sandbox Code Playgroud)
有关此的更多信息,请参阅此博客。
我建议您可以检查一下Resource Id
格式。正确的格式如/subscriptions/***************/resourceGroups/westus-mykeyvault/providers/Microsoft.KeyVault/vaults/shuisfsvault
。您可以首先在Azure Portal上创建SF群集。
如果仍然无法使用,建议您检查一下密钥库,是否给予足够的权限?
注意:对于测试,您可以将所有权限授予用户。
归档时间: |
|
查看次数: |
2887 次 |
最近记录: |