Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-AzureRmDataLakeStoreAccount + KeyVault throws: The service principal of the Data Lake Store account [account name] does not have access to the Key Vault [key vault id] #4323

Closed
cmendible opened this issue Jul 18, 2017 · 4 comments
Assignees
Labels
Data Lake Service Attention This issue is responsible by Azure service team.

Comments

@cmendible
Copy link
Member

cmendible commented Jul 18, 2017

Cmdlet(s)

New-AzureRmDataLakeStoreAccount

PowerShell Version

5.1.14393.1198

Module Version

4.2.0

OS Version

10.0.14393.1198

Description

We have a script which creates a Key Vault a Key Vault Key and then a Data Lake Account encrypted with the Key Vault.

The script looks like this:

$keyVault = New-AzureRmKeyVault `
    -VaultName $vaultName `
    -ResourceGroupName  $resourceGroupName `
    -Location $resourceGroupLocation

$key = Add-AzureKeyVaultKey `
    -VaultName $vaultName `
    -Name "DataLakeKey" `
    -KeyFilePath $dataLakeCertFile `
    -KeyFilePassword $secDataLakeCertPassword

$dataLakeStore = New-AzureRmDataLakeStoreAccount `
            -ResourceGroupName $resourceGroupName `
            -Name $dataLakeStoreName `
            -Location $resourceGroupLocation `
            -Encryption "UserManaged" `
            -KeyVaultId $keyVault.ResourceId `
            -KeyName $key.Name `
            -KeyVersion $key.Version

Set-AzureRmKeyVaultAccessPolicy `
        -VaultName $vaultName `
        -ObjectId (Get-AzureRmADServicePrincipal -SearchString "RN_$dataLakeStoreName").Where( {$_.DisplayName -eq "RN_$dataLakeStoreName"}).Id `
        -PermissionsToKeys encrypt, decrypt, get

# Enable the keyvault for the data lake
Enable-AzureRmDataLakeStoreKeyVault -ResourceGroupName $resourceGroupName -Account $dataLakeStoreName

So first we create the Vault, then the Data Lake which in turns creates the RN_$dataLakeStoreName service principal and finally add this principal to the Vault Policy and enable the Vault.

This works without issues in version 4.1.0 of the AzureRM module, but once you run it with version 4.2.0 the line calling New-AzureRmDataLakeStoreAccount throws:

The service principal of the Data Lake Store account [data lake name] does not have access to the Key Vault [key vault id]

The new version is trying to validate the service principal which is created with the datalake so it seems to be a "race condition". May be it's related to this new feature:

Added a quality of life update to automatically trigger an enableKeyVault call when a user managed KeyVault is added or a key is rotated.

Let me know if you need more info.

Thanks!

@cormacpayne
Copy link
Member

@begoldsm Hey Ben, would you mind taking a look at this issue?

@begoldsm
Copy link
Contributor

That is indeed the case. @cmendible it looks like we missed a scenario where the service principal to use doesn't already exist during initial setup of the Data Lake store account (in that you define it's permissions after account creation). To work around this for now you can either:

  • Revert back to the previous version of the ADLS cmdlets
  • Configure permissions with a pre-existing key vault SPN that already has access to the key vault.

Given your script and scenario I would recommend the first option. We will have this change reverted ASAP and it will be in for the next release.

@begoldsm
Copy link
Contributor

begoldsm commented Jul 18, 2017

@cmendible also, the account is successfully created (even with the failure) I believe. So you could do the following:

  • After account creation "failure":
    • Run the Set-AzureRMKeyVaultAccessPolicy cmdlet
    • Re-Run Enable-AzureRMDataLakeStoreKeyVault cmdlet.

@cmendible
Copy link
Member Author

Hi @begoldsm,

I was actually working on a video showing the script running and didn't want any red messages on it jejejeje.

I ended up reverting back to the previous version of the ADLS cmdlets.

I'll keep watching the issue so as soon as you release the fix I'll give it try and come to you guys with feedback.

ro-joowan added a commit to ro-joowan/azure-powershell that referenced this issue Jul 26, 2017
cormacpayne added a commit that referenced this issue Aug 2, 2017
Reverting change that resulted in issue #4323
@bsiegel bsiegel added the Service Attention This issue is responsible by Azure service team. label Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data Lake Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

5 participants