How to Create BlobServiceClient with linked service, SAS token or Service Principle

Shao Peng Sun 81 Reputation points
2022-09-30T04:37:50.57+00:00

I can create BlobServiceClient with the python SDK below. The "connection_string" is the connection_string I got from web console of Storage Account which including Access Key
blob_service_client = BlobServiceClient.from_connection_string(connection_string)

But now I don't have the access key of that Storage Account. What I have is a linked service to this Storage Account. And probably have SAS token or Service principle. But anybody could help how could I use linked service, SAS token or Service Principle to create BlobServiceClient with python?

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,336 questions
Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,664 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,415 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SaiKishor-MSFT 17,176 Reputation points
    2022-10-03T18:10:41.693+00:00

    @Shao Peng Sun Thanks for reaching out to Microsoft Q&A. I understand that you are looking for creating Blob Service Client with either Linked service, SAS token or service principle. Please correct me otherwise.

    Please refer to the below code snippets-

    Create blob service client using a shared access key- https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/storage/azure-storage-blob/samples/blob_samples_authentication.py#L66

    Create blob service client using ClientSecretCredential- https://github.com/Azure/azure-sdk-for-python/blob/master/sdk/storage/azure-storage-blob/samples/blob_samples_authentication.py#L88

    Create blob service client using Azure Identity- https://github.com/Azure/azure-sdk-for-python/blob/main/sdk/storage/azure-storage-blob/samples/blob_samples_authentication.py#L125

    This doc shows how to construct the BlobServiceClient Class using SAS - https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.blobserviceclient?view=azure-python

    Does this help? Please let me know. Thank you!

    Remember:

    Please accept an answer if correct. Original posters help the community find answers faster by identifying the correct answer. Here is how.

    Want a reminder to come back and check responses? Here is how to subscribe to a notification.

    0 comments No comments