Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gettting Error for Blob storage authantication #30686

Closed
rakshahulle opened this issue Jan 21, 2025 · 2 comments
Closed

Gettting Error for Blob storage authantication #30686

rakshahulle opened this issue Jan 21, 2025 · 2 comments
Assignees
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Milestone

Comments

@rakshahulle
Copy link

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

@rakshahulle rakshahulle added the bug This issue requires a change to an existing behavior in the product in order to be resolved. label Jan 21, 2025
@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Jan 21, 2025
@yonzhan
Copy link
Collaborator

yonzhan commented Jan 21, 2025

Thank you for opening this issue, we will look into it.

@yonzhan yonzhan added Azure CLI Team The command of the issue is owned by Azure CLI team question The issue doesn't require a change to the product in order to be resolved. Most issues start as that and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Jan 22, 2025
@yonzhan yonzhan added this to the Backlog milestone Jan 22, 2025
@calvinhzy
Copy link
Member

Hi @rakshahulle, from your provided info, it seems like an issue when using the Azure Python SDK, please raise an issue here instead as we are not sure about the authorization details in the SDK, thanks. https://github.com/Azure/azure-sdk-for-python/issues/new?template=bug_report.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Azure CLI Team The command of the issue is owned by Azure CLI team customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

3 participants