I have set up a serverless application that needs to be deployed on Azure. I have completed all the setup mentioned in the documentation. Whenever I am trying to run sls deploy
. It is giving:
Error: The client 'aa875774-ab8a-41e7-a567-0a4f0bc7cedc' with object id 'aa875774-ab8a-41e7-a567-0a4f0bc7cedc' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/SUBID/resourcegroups/sls-weur-dev-zucora-apps-rg' or the scope is invalid. If access was recently granted, please refresh your credentials.
at new RestError (/Users/raman/Documents/project/node_modules/@azure/ms-rest-js/dist/msRest.node.js:1403:28)
at /Users/raman/Documents/project/node_modules/@azure/ms-rest-js/dist/msRest.node.js:2592:37
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
I have tried adding the roles and permissions. The user that I am using is the admin user and has all the read and write permissions. But still getting the same error when deploying.
I am not able to see where to add RBAC in my permissions as mentioned here.
This deployment only contains functions.
The below image contains the screenshot for the IAM Access Control for the subscription. The user has both Owner and Contributor roles.
The below Screenshot contains the serverless.yml
I then created a new account and followed all the steps for a new account, and I am still getting the same error.
2
Answers
After weeks of Research and hit and try, I have found a solution which worked for me.
After following all the steps mentioned in the question, I had to assign the contributor role using the azure cli.
As Azure RBAC (role-based access control) has these scopes in order - Management group -> Subscription -> Resource group -> Resources.
I assigned the role using:
And After that I exported all IDs and secrets form here:
After that things started to work for me.
I got the same error when I tried to deploy the serverless azure function using
sls deploy
:To resolve this error, you should assign Contributor role to the User in the Subscription.
Portal:
Hello function:
Goodbye function: