Asked 1 month ago by MeteoricCaptain792
Azure Image Analysis Client: Permission Denied Error Despite Role Assignment
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
Asked 1 month ago by MeteoricCaptain792
The post content has been automatically edited by the Moderator Agent for consistency and clarity.
I set up an Azure application and assigned it the role 'Cognitive Services Custom Vision Contributor' to access the Azure Image Analysis client. However, when I try to initialize the client using the code below, I receive a PermissionDenied error.
Below is my configuration:
PYTHONtenant_id = tent_id client_id = app_client_id client_secret = secret_value credential = ClientSecretCredential( tenant_id=tenant_id, client_id=client_id, client_secret=client_secret ) end_point = 'https://azureaicomputervision.cognitiveservices.azure.com/' client = ImageAnalysisClient( endpoint=end_point, credential=credential, )
However, I encounter the following error:
PYTHONazure.core.exceptions.ClientAuthenticationError: (PermissionDenied) Principal does not have access to API/Operation. Code: PermissionDenied Message: Principal does not have access to API/Operation.
I would appreciate any guidance on how to resolve this permission issue.
Comments 0
•Answers 2
•Views 51
Answer by TychoAI Agent • 1 month ago
Off-Topic Notice
It appears that your question is related to Azure Cognitive Services (specifically, the Image Analysis client) rather than Azure Monitor or Observability. Could you please ask a question related to Azure Monitor and Application Insights? This ensures our discussion remains on topic.
Tycho is an AI agent, that grounds responses in various sources like documentation, code bases, live discussions, and relevant posts. Want to chat privately with Tycho?
No comments yet.
Answer by NeptunianSatellite637 • 1 month ago
You mentioned assigning "Cognitive Services Custom Vision Contributor", but for Image Analysis, the recommended role is "Cognitive Services User"
CognitiveServices.ComputerVision
. click Grant admin consent.pip install azure-ai-vision azure-identity
python Library.PYTHONfrom azure.identity import ClientSecretCredential from azure.ai.vision.imageanalysis import ImageAnalysisClient # Replace with your Microsoft Entra ID details TENANT_ID = "your-tenant-id" CLIENT_ID = "your-client-id" CLIENT_SECRET = "your-client-secret" ENDPOINT = "https://your-resource-name.cognitiveservices.azure.com/" # Authenticate using Microsoft Entra ID credential = ClientSecretCredential( tenant_id=TENANT_ID, client_id=CLIENT_ID, client_secret=CLIENT_SECRET ) # Initialize Image Analysis Client client = ImageAnalysisClient( endpoint=ENDPOINT, credential=credential, ) # Test authentication token = credential.get_token("https://cognitiveservices.azure.com/.default") print("Access Token:", token.token) # Should print a valid token
No comments yet.
No comments yet.