Tried this question.
I'm running this code locally in VSCODE, and am logged in using az login
. I've also tried aad_credentials = AzureCliCredential()
with the same result. Left out the details of creating the group.
aad_credentials = DefaultAzureCredential()
URI = environ.get("DPS_ENDPOINT")
client = DeviceProvisioningClient(endpoint=URI, credential=aad_credentials)
group_id = 'symetric_group_test'
enrollment_group = {
"enrollmentGroupId": group_id,
"attestation": {
"type": "symmetricKey"
}
}
client.enrollment_group.create_or_update( id=group_id, enrollment_group=enrollment_group
Response:
azure.core.exceptions.ClientAuthenticationError: (None) Authorization failed for the request
Code: None
Message: Authorization failed for the request
adding logging_enable=True
did not provide any output.
Anything hints or directions on how to debug?
UPDATE: Same error in Azure Cloud Shell.
this might be the issue. I have permissions in portal, but in clis:
az role assignment list --assignee []
@Sridevi was correct. It was a permissions issue.
Device Provisioning Service Data Contributor
is the required permission. I think a 403 (I know who you are and you lack permission) would be a better code than None. Although it might be more useful to post that in github.