In order to perform Automated Azure Storage account Access keys, I am following this article: https://learn.microsoft.com/en-us/azure/key-vault/secrets/tutorial-rotation-dual?tabs=azure-cli#create-and-deploy-the-key-rotation-function
Since I have 500+ Azure Storage Accounts each with two Access keys , which procedure should I follow to ensure each of the Azure Storage Accounts Access keys are rotated daily for both keys?
Should I follow this: https://learn.microsoft.com/en-us/azure/key-vault/secrets/tutorial-rotation-dual?tabs=azure-cli#add-the-storage-account-access-keys-to-key-vault-secrets
Set-AzKeyVaultAccessPolicy -UserPrincipalName '******@company.com' -name vaultrotation-kv -PermissionsToSecrets set, delete, get, list
$tomorrowDate = (Get-Date).AddDays(+ 1).ToString('yyy-MM-ddTHH:mm:ssZ')
$secretValue = ConvertTo-SecureString -String '<key1Value>' -AsPlainText -Force
$tags = @{
CredentialId = 'key1'
ProviderAddress = '<storageAccountResourceId>'
ValidityPeriodDays = '1' #set to 1 day or 24 hours
}
Set-AzKeyVaultSecret -Name storageKey -VaultName vaultrotation-kv -SecretValue $secretValue -Tag $tags -Expires $tomorrowDate
$tomorrowDate = (Get-Date).AddDays(+ 1).ToString('yyy-MM-ddTHH:mm:ssZ')
$secretValue = ConvertTo-SecureString -String '<key2Value>' -AsPlainText -Force
$tags = @{
CredentialId = 'key2'
ProviderAddress = '<storageAccountResourceId>'
ValidityPeriodDays = '1' #set to 1 day or 24 hours
}
Set-AzKeyVaultSecret -Name storageKey -VaultName vaultrotation-kv -SecretValue $secretValue -Tag $tags -Expires $tomorrowDate
or this one: https://learn.microsoft.com/en-us/azure/key-vault/secrets/tutorial-rotation-dual?tabs=azurepowershell#use-existing-rotation-function-for-multiple-storage-accounts