I've tried the preview of DefaultAzureCredential with Az Cli credential support, but DefaultAzureCredential doesn't seem to recognize my login, I'm currently logged in into the azure subscription as a contributor (the object storage service is within the same subscription). Here is the codesnippet I use:
import os
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient
account_name = os.getenv('AZURE_STORAGE_ACCOUNT_NAME')
container_name = os.getenv('AZURE_CONTAINER_NAME')
my_storage_account_url = "https://{}.blob.core.windows.net/".format(account_name)
credential = DefaultAzureCredential()
blob_service_client = BlobServiceClient(account_url=my_storage_account_url,
credential=credential)
blob_name = "myfile.jpg"
file_stream = open("myfile.jpg", "rb")
blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)
blob_client.upload_blob(file_stream)
Here is the error I get:
azure.core.exceptions.ClientAuthenticationError:
No credential in this chain provided a token.
Attempted credentials:
EnvironmentCredential: Incomplete environment configuration. See https://aka.ms/python-sdk-identity#environment-variables for expected environment variables
ManagedIdentityCredential: IMDS endpoint unavailable
SharedTokenCacheCredential: The shared cache contains no signed-in accounts. To authenticate with SharedTokenCacheCredential, login
through developer tooling supporting Azure single sign on
Before running the code, i've logged in with az login successfully.
I use python 3.7.6 64-bit
SDK's:
Name: azure-identity
Version: 1.4.0b1
Name: azure-storage-blob
Version: 12.3.0
Thanks a lot!
Originally posted by @kevroes in #9002 (comment)
I've tried the preview of DefaultAzureCredential with Az Cli credential support, but DefaultAzureCredential doesn't seem to recognize my login, I'm currently logged in into the azure subscription as a contributor (the object storage service is within the same subscription). Here is the codesnippet I use:
Here is the error I get:
Before running the code, i've logged in with
az loginsuccessfully.I use python 3.7.6 64-bit
SDK's:
Name: azure-identity
Version: 1.4.0b1
Name: azure-storage-blob
Version: 12.3.0
Thanks a lot!
Originally posted by @kevroes in #9002 (comment)