I am trying to connect to Azure data lake storage using connection_string with my personal account. Using which, I can make connection and work with blobs.
Now, I have received below 4 keys and want to see if there is function we can generate connection_string from it using python?
I know, I can use the keys and work with it. But wanted to explore if there is this option available.
Python code:
from azure.storage.filedatalake import DataLakeServiceClient
from azure.identity import ClientSecretCredential
TENANT_ID = 'XXX'
CLIENT_ID = 'XXX'
CLIENT_SECRET = 'XXX'
STORAGE_ACCOUNT_NAME = 'XXX'
credential = ClientSecretCredential(TENANT_ID, CLIENT_ID, CLIENT_SECRET)
service_client = DataLakeServiceClient(account_url="{}://{}.dfs.core.windows.net".format(
"https", STORAGE_ACCOUNT_NAME), credential=credential)
No, you cannot.
The connection string
and the service principal
(the keys you mentioned like CLIENT_ID
/ CLIENT_SECRET
) are different authorization solution, you cannot convert one to another.
By the way, to authenticate the client you have a few options, and you cannot mix them:
1.Use a SAS token string
2.Use an account shared access key
3.Use a token credential from azure.identity
(like using service principal)
4.Connection string