databricks-cli icon indicating copy to clipboard operation
databricks-cli copied to clipboard

Authentication is temporarily unavailable when creating Azure keyvault backed secret scope

Open JCZuurmond opened this issue 4 years ago • 41 comments

We get the following message when creating a secret scope with an Azure keyvault back end in the CI.

 { 'error_code': 'TEMPORARILY_UNAVAILABLE',
  'message': 'Authentication is temporarily unavailable. Please try again '
             'later.'}

Locally it works, the aad-token is set in the CI script, I have tried it at different times. Anyone can help with what to do with this message?

JCZuurmond avatar Oct 12 '20 08:10 JCZuurmond

Hi,

we observed a same issue. Its connected to aad-token authorization. I am able to connect and list secret scopes but not to create a new one.

We tried to call Databricks API directly but it is same there (so it is not problem of CLI). We are not able to deploy ntbs or create secret scope with AAD token.

michalmlaka avatar Oct 22 '20 08:10 michalmlaka

@michalmlaka : Thanks for adding that it is an API thing. We'll see if they fix it there.

JCZuurmond avatar Oct 22 '20 11:10 JCZuurmond

This currently does not work with AAD tokens acquired with Service principals

“Service Principals cannot be used with the AKV secret integration. This is because they do not support the on-behalf-of flow. We are requesting this of the AAD team and working on documenting it. You need to use a user's AAD token.”

In the interim, use below approach to create secret scope using user's AAD token

Obtain token using user creds

from adal import AuthenticationContext

authority_host_url = "https://login.microsoftonline.com/"
# the Application ID of  AzureDatabricks
azure_databricks_resource_id = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d"

# Required user input
user_parameters = {
   "tenant" : "fa5cf446-0f25-4992-9e15-8723c0a0b170",
   "client_id" : "5662111a-38a8-403c-9d9a-f9b690985796",
   "username" : "user_upn",
   "password" : "xxxxxxxxxxxxxxxxx"
}

# configure AuthenticationContext
# authority URL and tenant ID are used
authority_url = authority_host_url + user_parameters['tenant']
context = AuthenticationContext(authority_url)

# API call to get the token
token_response = context.acquire_token_with_username_password(
  azure_databricks_resource_id,
  user_parameters['username'],
  user_parameters['password'],
  user_parameters['client_id']
)

access_token = token_response['accessToken']
refresh_token = token_response['refreshToken']
access_token

REST API request to create secret scope

POST https://adb-6187942982036570.10.azuredatabricks.net/api/2.0/secrets/scopes/create HTTP/1.1
Authorization: Bearer <token>

# For Keyvault backed scope
{
    "scope":  "restapiaad-keyvault-scope",
    "initial_manage_principal":  "users",
    "backend_azure_keyvault":  {
                                   "dns_name":  "https://aravish369vault.vault.azure.net/",
                                   "resource_id":  "/subscriptions/f34f9848-8b93-4cfb-9ced-0c4548a74cce/resourceGroups/aravishexternalrsgrp/providers/Microsoft.KeyVault/vaults/aravish369vault"
                               },
    "scope_backend_type":  "AZURE_KEYVAULT"
}

aravish avatar Nov 03 '20 19:11 aravish

I am able to authenticate with AAD tokens to create a databricks personal access token, then authenticate again with the api using the databricks token to create secret scopes. I'm not sure if that works with keyvault backends, but I was running into the same issue just creating databricks backend scopes

gramhagen avatar Nov 06 '20 16:11 gramhagen

@gramhagen, Ultimately the AAD token should be used to create the secret scopes which should work as expected and not run into issues.

aravish avatar Nov 11 '20 14:11 aravish

Unfortunately does not working. Run into these issues:

https://forums.databricks.com/questions/50626/azure-databricks-api-20-cant-create-azure-keyvault.html

michalmlaka avatar Nov 26 '20 11:11 michalmlaka

@aravish , Is there ETA to fix the issue that unable to create Azure Key Vault scope using Service Principal token? Using user AAD token is not a good solution for automation that is running on service principal. We cannot store personal password in automation.

We are automating the Azure databricks configuration, including Azure resource creation, databricks cluster creation, Azure key Vault secret scope creation with CI/CD. This issue is blocking us to automate the process.

hannwang1 avatar Dec 22 '20 01:12 hannwang1

I believe the PMs were talking to msft about enabling AKV creation with service principal tokens. @annashres might be the best person to talk to about this?

sushi1998 avatar Dec 22 '20 19:12 sushi1998

I believe the PMs were talking to msft about enabling AKV creation with service principal tokens. @AnnaShrestinan might be the best person to talk to about this?

Thanks @sushi1998 for the info. How to contact AnnaShrestinan?

hannwang1 avatar Dec 23 '20 01:12 hannwang1

We tried it once again. It looks better now. (error msg.).

{"error_code":"CUSTOMER_UNAUTHORIZED","message":"Unable to grant read/list permission to Databricks service principal to KeyVault 'https://keyvaultname.vault.azure.net/': key not found: https://graph.windows.net/"}(base)

I assigned "Directory.Read.All" permission for AAD Graph API (https://graph.windows.net/). But it is not enough. What else do I need?

michalmlaka avatar Feb 02 '21 08:02 michalmlaka

I think we are waiting to hear from @AnnaShrestinan like @sushi1998 mentioned. To the best of my knowledge it does not have to do with setting the right permissions for your SP.

JCZuurmond avatar Feb 02 '21 16:02 JCZuurmond

Any update on this, i am running into the same issue?

KevSpally-collab avatar Mar 21 '21 07:03 KevSpally-collab

Not that I am aware off. What I know: databricks people are talking to Azure people. It most likely takes a while: months not weeks

JCZuurmond avatar Mar 22 '21 07:03 JCZuurmond

+1 same issue here. Please fix it. Creating a Secret Scope using a Service Principal with AAD Token is still not working.

emerrf avatar Mar 26 '21 11:03 emerrf

Same issue here, please fix as in my company the only way we can do things in higher envs is with SPN so it is not possible to config any other way!

dkataria1990 avatar Apr 01 '21 16:04 dkataria1990

We are working with Azure to enable the use of Service Principals for creating an AKV-backed secret scope. @hpsin from Azure AD will have updates on the timeline.

annashres avatar Apr 01 '21 18:04 annashres

@annashres @hpsin Has there been any updates on this with timelines etc.? The alternative way is just too much rework for CI/CD processes right now, especially as I am using a regular SP for everything else in the Databricks CLI

Thanks

mcalnd70 avatar Apr 26 '21 09:04 mcalnd70

Any updates on this? I am also having issues trying to set up key vault backed secret scope.

eosho avatar May 26 '21 15:05 eosho

+1 only manual step in a huge deployment currently. Any updates on this? @hpsin

ivo-o avatar Jun 08 '21 12:06 ivo-o

We don't have timelines to announce right now on when SP impersonation is going to be supported. We're investigating how we build this - it requires the creation of a new class of scopes (delegation scopes for service principals) and updating the authorization logic of every API. We understand the importance of this feature for automation flows, and building it securely is our number one concern.

hpsin avatar Jun 08 '21 18:06 hpsin

We don't have timelines to announce right now on when SP impersonation is going to be supported. We're investigating how we build this - it requires the creation of a new class of scopes (delegation scopes for service principals) and updating the authorization logic of every API. We understand the importance of this feature for automation flows, and building it securely is our number one concern.

thanks for the update 👌

m1nkeh avatar Jun 08 '21 21:06 m1nkeh

is this still in progress... Any updates !

atul-ram avatar Nov 09 '21 16:11 atul-ram

@hpsin why not just use a managed identity like azure datafactory ?? this will probably also solve some other problems related to cloud auth, currently when creating scope on UI, how the refresh token is passed to clusters ?? is the user AAD Token stored somewhere permanently ??, what happens if the user token is revoked ??

choukimasri avatar Nov 29 '21 12:11 choukimasri

Any updates on this? @hpsin @annashres

mallecespedes avatar Mar 01 '22 17:03 mallecespedes

The creation of a new class of scope is almost complete, and the team is hoping to test soon. @psignoret and @annashres should be able to provide updates from here as I've transitioned away from Azure AD.

hpsin avatar Mar 03 '22 18:03 hpsin

Just checking in to see how this request is tracking? Lots of users are eagerly awaiting this capability!

jaokeeffe avatar Apr 05 '22 04:04 jaokeeffe

+1 looking for update on this one

lordlinus avatar May 30 '22 02:05 lordlinus

+1 @annashres and @psignoret, could you give the community an update regarding this issue? We are all eagerly waiting for this feature's arrival!

anocendi avatar Jun 08 '22 04:06 anocendi

+1 I run into same issue. Any updates after 1.5 years?

dabruehl avatar Jun 13 '22 10:06 dabruehl

@annashres @hpsin any update?

mwillebrands avatar Jul 21 '22 15:07 mwillebrands