我的客户端密钥已过期,因此我需要更新密钥,如何使用 azure 门户更新 Azure 数据工厂中的 Azure 密钥保管库中的密钥。
如何在 Azure 密钥保管库中更新新的客户端密钥,以及如何设置过期日期
最初,我注册了一个 Azure AD 应用程序并在其中创建了客户端密钥,如下所示:
在我的 Azure 密钥保管库中,我添加了一个具有上述值的秘密,如下所示:
要在 Azure AD 应用程序注册中创建 new 客户端密钥和 update 密钥保管库密钥值,您可以在 Azure Cloud Shell 中运行以下 PowerShell 脚本:
$resourceGroupName = "YourRGname"
$keyVaultName = "YourKVname"
$secretName = "YourKBsecretname"
$appName = "YourAzureADappName"
$existingSecret = Get-AzKeyVaultSecret -VaultName $keyVaultName -Name $secretName -AsPlainText
Write-Output "Existing secret value: $existingSecret"
$customKeyIdentifier = "newSecret"
$customKeyIdentifierBase64 = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($customKeyIdentifier))
$clientSecret = New-AzADAppCredential -DisplayName $appName -CustomKeyIdentifier $customKeyIdentifierBase64 -EndDate (Get-Date).AddYears(1)
$secretValue = ConvertTo-SecureString -String $clientSecret.SecretText -AsPlainText -Force
Set-AzKeyVaultSecret -VaultName $keyVaultName -Name $secretName -SecretValue $secretValue
Write-Output "New client secret created and updated in Key Vault successfully."
$newSecret = Get-AzKeyVaultSecret -VaultName $keyVaultName -Name $secretName -AsPlainText
Write-Output "New secret value: $newSecret"
回复:
为了确认,我在门户中检查了相同的内容,其中在 Azure AD 应用程序中创建了新的客户端密钥,如下所示:
也在 Azure Key Vault 中,通过创建新版本,成功使用新的客户端密钥值更新了密钥,如下所示: