Я использую статью Microsoft для обновления сертификата HDInsight. Я хотел знать, повлияет ли обновление сертификата, если есть какие-либо работающие задания?
У нас есть аналогичный процесс обновления сертификата для учетных записей автоматизации. Я протестировал это для учетной записи автоматизации, создав долго работающий модуль Runbook и инициировав обновление сертификата. Код обновления сертификата не повлиял на выполнение модуля Runbook.
Я хотел проверить, пробовал ли кто-нибудь это для HDInsight.
$clusterName = '<clustername>'
$resourceGroupName = '<resourcegroupname>'
$subscriptionId = '01234567-8a6c-43bc-83d3-6b318c6c7305'
$appId = '01234567-e100-4118-8ba6-c25834f4e938'
$addNewCertKeyCredential = $true
$certFilePath = 'C:\localfolder\adls.pfx'
$KeyVaultName = "my-key-vault-name"
$KeyVaultSecretName = "my-key-vault-secret-name"
$certPassword = Read-Host "Enter Certificate Password"
# certSource
# 0 - create self signed cert
# 1 - read cert from file path
# 2 - read cert from key vault
$certSource = 0
Login-AzAccount
Select-AzSubscription -SubscriptionId $subscriptionId
if($certSource -eq 0)
{
Write-Host "Generating new SelfSigned certificate"
$cert = New-SelfSignedCertificate -CertStoreLocation "cert:\CurrentUser\My" -Subject "CN=hdinsightAdlsCert" -KeySpec KeyExchange
$certBytes = $cert.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $certPassword);
$certString = [System.Convert]::ToBase64String($certBytes)
}
elseif($certSource -eq 1)
{
Write-Host "Reading the cert file from path $certFilePath"
$cert = new-object System.Security.Cryptography.X509Certificates.X509Certificate2($certFilePath, $certPassword)
$certString = [System.Convert]::ToBase64String([System.IO.File]::ReadAllBytes($certFilePath))
}
elseif($certSource -eq 2)
{
Write-Host "Reading the cert file from Azure Key Vault $KeyVaultName"
$cert = (Get-AzureKeyVaultSecret -VaultName $KeyVaultName -Name $KeyVaultSecretName)
$certValue = [System.Convert]::FromBase64String($cert.SecretValueText)
$certObject = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2 -ArgumentList $certValue, $null,"Exportable, PersistKeySet"
$certBytes = $certObject.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Pkcs12, $certPassword.SecretValueText);
$certString =[System.Convert]::ToBase64String($certBytes)
}
if($addNewCertKeyCredential)
{
Write-Host "Creating new KeyCredential for the app"
$keyValue = [System.Convert]::ToBase64String($cert.GetRawCertData())
New-AzADAppCredential -ApplicationId $appId -CertValue $keyValue -EndDate $cert.NotAfter -StartDate $cert.NotBefore
Write-Host "Waiting for 7 minutes for the permissions to get propagated"
Start-Sleep -s 420 #7 minutes
}
Write-Host "Updating the certificate on HDInsight cluster..."
Invoke-AzResourceAction `
-ResourceGroupName $resourceGroupName `
-ResourceType 'Microsoft.HDInsight/clusters' `
-ResourceName $clusterName `
-ApiVersion '2015-03-01-preview' `
-Action 'updateclusteridentitycertificate' `
-Parameters @{ ApplicationId = $appId; Certificate = $certString; CertificatePassword = $certPassword.ToString() } `
-Force