How to use System Assigned MI to access Blob Storage and Cosmos DB in Synapse Analytics
Haria, Neel
0
Reputation points
Hi,
I am trying leverage the default system assigned managed identity a synapse workspace provides to access blob storage and cosmos db.
I have already tried the following steps which I saw in various posts:
- Assign Role to Managed Identity:
- Navigate to your Blob Storage account in the Azure portal.
- Go to the "Access control (IAM)" section.
- Click on "Add" and then "Add role assignment".
- Assign the role of "Storage Blob Data Contributor" to the managed identity associated with your Synapse workspace.
- Use Managed Identity in Synapse Notebook:
- When running your Spark notebooks, enable "Run as managed identity" from the Configure session menu.
- You can now access Blob Storage using the managed identity without needing to manage credentials manually.
- Code snippet I am using
# Install the required packages #!pip install azure-identity azure-storage-blob # Import necessary libraries from azure.identity import ManagedIdentityCredential from azure.storage.blob import BlobServiceClient # Create a managed identity credential object credential = ManagedIdentityCredential() # Create a BlobServiceClient object using the managed identity credential blob_service_client=BlobServiceClient(account_url="https://
Sign in to answer