1
votes

When i am running python script to manage vm's on azure environment its getting failed due to AuthorizationFailed message. Following exception are getting printed along with the error message.

CloudError("The client 'bdafca09-d426-4924-b63c-dff61c034187' with object id 'bdafca09-d426-4924-b63c-dff61c034187' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/49ec57ce-8a6f-4cdf-95bf-8163b231edf6/resourcegroups/azure-sample-group-virtual-machines' or the scope is invalid. If access was recently granted, please refresh your credentials.")

1

1 Answers

1
votes

You need to add Contributor role for the application you created in Azure AD in the portal.

  1. Select your subscription in Subscriptions(search Subscriptions in the top bar)

enter image description here

  1. Add role assignment in Access control

enter image description here

  1. select and add the Contributor role for your application.

enter image description here

  1. If you add it successfully, you will see your application showing in the role assignment list.

enter image description here