Skip to content

Gettting Error for Blob storage authantication #30686

@rakshahulle

Description

@rakshahulle

Describe the bug

Error downloading blob: This request is not authorized to perform this operation using this permission.
RequestId:7fd133fa-401e-0026-1935-6ce53f000000
Time:2025-01-21T18:48:12.0414663Z
ErrorCode:AuthorizationPermissionMismatch
Content: AuthorizationPermissionMismatchThis request is not authorized to perform this operation using this permission.
RequestId:7fd133fa-401e-0026-1935-6ce53f000000
Time:2025-01-21T18:48:12.0414663Z

Related command

Need solution

Errors

Error downloading blob: This request is not authorized to perform this operation using this permission.
RequestId:7fd133fa-401e-0026-1935-6ce53f000000
Time:2025-01-21T18:48:12.0414663Z
ErrorCode:AuthorizationPermissionMismatch
Content: AuthorizationPermissionMismatchThis request is not authorized to perform this operation using this permission.
RequestId:7fd133fa-401e-0026-1935-6ce53f000000
Time:2025-01-21T18:48:12.0414663Z

Issue script & Debug output

import os
from azure.identity import DefaultAzureCredential
from azure.storage.blob import BlobServiceClient

Replace with your actual storage account name

account_url = "https://.blob.core.windows.net"
credential = DefaultAzureCredential()

Create the BlobServiceClient object

blob_service_client = BlobServiceClient(account_url, credential=credential)

print(blob_service_client)

def download_blob_to_file(blob_service_client: BlobServiceClient, container_name: str, blob_name: str, download_file_path: str):
try:
# Get the blob client
blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)

    # Ensure the directory exists
    os.makedirs(os.path.dirname(download_file_path), exist_ok=True)
    
    # Download the blob and save it locally
    with open(file=download_file_path, mode="wb") as file:
        download_stream = blob_client.download_blob()
        file.write(download_stream.readall())
    print(f"Blob '{blob_name}' downloaded successfully to '{download_file_path}'.")
except Exception as ex:
    print(f"Error downloading blob: {ex}")

Call the function

download_blob_to_file(blob_service_client, container_name="car", blob_name="RAV4.pdf", download_file_path=r"pdf/p1.pdf")

Expected behavior

Downloaded file from Blob Storage

Environment Summary

azure-cli 2.68.0

core 2.68.0
telemetry 1.1.0

Dependencies:
msal 1.31.1
azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3'
Extensions directory '/home/raksha/.azure/cliextensions'

Python (Linux) 3.12.8 (main, Jan 8 2025, 03:38:17) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date

Additional context

No response

Metadata

Metadata

Assignees

Labels

Azure CLI TeamThe command of the issue is owned by Azure CLI teamcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.questionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions