title: Rotate Encryption Keys Azure Data Lake Store
body: <p>I have created a PowerShell Script which creates a new version of User Managed Encryption Key in Azure Key Vault and update the Data Lake Store Encryption Key to the new version. Below is the script</p>
  
  <pre><code>$subscriptionID = 'XXXX'
  $keyVaultName = 'XXXX'
  $keyName = 'XXXX'
  $adlsName = 'XXXX'
  
  Login-AzureRmAccount
  Select-AzureRmSubscription -SubscriptionId $subscriptionID
  
  $azureKVKey = Add-AzureKeyVaultKey -VaultName $keyVaultName -Name $keyName -Destination Software
  $adlsKVVersion = $azureKVKey.Version
  
  Set-AzureRmDataLakeStoreAccount -Name $adlsName -KeyVersion $adlsKVVersion
  (Get-AzureRmDataLakeStoreAccount -Name $adlsName).Properties.EncryptionConfig.KeyVaultMetaInfo.EncryptionKeyVersion
  </code></pre>
  
  <p>The script successfully creates a new version of the key but the ADLS encryption key version does not change.</p>
  
  <p>I debugged it and I can also see that the the PS command sends a request for updating the encryption key version</p>
  
  <p><a href="https://i.stack.imgur.com/7SRjg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7SRjg.png" alt="PS Request body"></a></p>
  
  <p>The response of the PS script still shows the old version of the encryption key
  <a href="https://i.stack.imgur.com/jn8QK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jn8QK.png" alt="PS Response body"></a></p>
  
  <p>Any hints as to what might be going wrong?</p>
  
  <p>Thanks</p>