Azure-Functions icon indicating copy to clipboard operation
Azure-Functions copied to clipboard

RBAC reader role does not work with Azure Functions

Open hamptont opened this issue 8 years ago • 17 comments

I am trying to use RBAC to grant read-only access to my Azure Functions to share read-only access of my Function code and function execution logs.

When I log in with the user that has been grated RBAC read access, I can view the Azure Function resource itself in Azure, but I cannot load any of the functions. This prevents me from viewing the code or function logs.

Note: I tested with RBAC contributor permission, and that works, but that is granting more permission than I want to grant as the user also gets write access.

image

hamptont avatar Dec 21 '17 00:12 hamptont

Can you provide steps to reproduce this?

patricklee2 avatar Dec 28 '17 01:12 patricklee2

Hi Patrick,

I am following the steps from the below document, but on step 10, assign 'reader' role rather than 'contributor' role: https://github.com/Microsoft/AppSource/blob/master/Troubleshooting/GrantMicrosoftAccessToYourAzureResourceGroup.md

Note the reader role is assigned to a guest user from another tenant (invited with Azure B2B) and not home tenant user.

Note that the above document has been updated to assign the 'contributor' role as the 'reader' role was not working. Ideally in step 10, we could assign the 'reader' role instead of the 'contributor' role, but the read access is not working, so I had to switch it to contributor role to unblock our scenario.

FYI I work at Microsoft you can ping me internally if you prefer

hamptont avatar Jan 02 '18 18:01 hamptont

I reproduced the error. Also trying to expand the Function App returns a 403 error in the console. "{"error":{"code":"AuthorizationFailed","message":"The client 'X' with object id 'X' does not have authorization to perform action 'Microsoft.Web/sites/config/list/action' over scope '/subscriptions/X/resourceGroups/X/providers/Microsoft.Web/sites/X/config/authsettings'."}}"

patricklee2 avatar Jan 02 '18 21:01 patricklee2

This is blocked by design, in case the code or config contains secrets that can be used to gain write access.

You can try to make a custom role for your use case. https://docs.microsoft.com/en-us/azure/active-directory/role-based-access-control-custom-roles

patricklee2 avatar Jan 02 '18 21:01 patricklee2

Thanks Patrick. I will look into custom roles but I worry this may add too much over head for our use case.

Using the provided roles, what is the least privileged role I can use that will allow me full read access to the Azure Functions? I am currently using 'contributor' role and it seems to work (but this also grants write access which is not ideal). Is there a way to grant full read access but no write access using out of the box roles? Or do I need to make a custom role to support this scenario?

hamptont avatar Jan 03 '18 22:01 hamptont

the 'contributor' role will provide full read access.
There is no built-in role that support your scenario, you will need to make a custom role.

If there are secret/keys in the code then a reader can potentially gain write access. So a custom role with read access to the code may be equivalent to a contributor from a security standpoint.

patricklee2 avatar Jan 03 '18 23:01 patricklee2

Even with a custom role you have to give the user write access which seems rather backwards. You are trying to prevent someone from accidentally exposing secrets/keys that would could be used to become a writer by forcing us to give write access to someone we want to be a reader.

mjhoffman avatar Mar 07 '18 19:03 mjhoffman

Hey anyone have JSON for custom role to achieve this, we use VSTS (SPI) to deploy to functions, but would require devs to be able to see if code has been deployed correctly?

allanmoller avatar Mar 22 '18 11:03 allanmoller

Hi, Its been 6 months. we came across exactly same permission like this. but as per our discussion with Microsoft support, Even with the custom RBAC this is not possible. The inbuilt permissions doesn't provide the granularity.

I am updating this thread, so in future no body spent time to identify this.

hsakarp63 avatar Sep 20 '18 06:09 hsakarp63

Need help on this, we are also facing same problem. Please advice which RBAC permissions are suitable for this requirement.

pvvdurgaprasad avatar Mar 11 '19 09:03 pvvdurgaprasad

I guess this will solve your problem... you can add the below permissions to a custom role as you require.

microsoft.web/sites/functions/action
microsoft.web/sites/functions/delete
microsoft.web/sites/functions/listsecrets/action microsoft.web/sites/functions/read
microsoft.web/sites/functions/write
microsoft.web/sites/functions/masterkey/read
microsoft.web/sites/functions/token/read

PS Cmd : Get-AzProviderOperation "Microsoft.web/sites/functions/*" | FT

Kalaiyarasanak avatar May 24 '19 08:05 Kalaiyarasanak

@mjhoffman nailed it. "You are trying to prevent someone from accidentally exposing secrets/keys that would could be used to become a writer by forcing us to give write access to someone we want to be a reader."

If people can't or won't use KeyVault to protect their secrets, that's their concern. Do not try to create compliance through circular logic. The reader role should work for Azure Functions as requested earlier in this thread.

This is like "Big Brother" stepping in and outlawing bacon to protect the one person that eats too much bacon, ruining it for everybody else.

Just add a big warning somehow. Or include a special role like "Azure Functions Reader-WithConfigVisibility", followed by "Azure Functions Reader-WithoutConfigVisibility"

willdaviesdevelops avatar Sep 05 '19 19:09 willdaviesdevelops

@patricklee2 can you please update status on this?

hkusulja avatar Feb 10 '22 09:02 hkusulja

@mjhoffman nailed it. "You are trying to prevent someone from accidentally exposing secrets/keys that would could be used to become a writer by forcing us to give write access to someone we want to be a reader."

If people can't or won't use KeyVault to protect their secrets, that's their concern. Do not try to create compliance through circular logic. The reader role should work for Azure Functions as requested earlier in this thread.

This is like "Big Brother" stepping in and outlawing bacon to protect the one person that eats too much bacon, ruining it for everybody else.

Just add a big warning somehow. Or include a special role like "Azure Functions Reader-WithConfigVisibility", followed by "Azure Functions Reader-WithoutConfigVisibility"

I agree here. Microsoft does a good job pushing the protection of secrets using Key Vault. There should be a permission that provides read-only access to app configurations for the purpose of verification. It is 100% my responsibility to protect those secrets, which we do.

trevonmckay avatar Dec 21 '22 21:12 trevonmckay

Submitted this on the Azure Feedback forum, please vote - https://feedback.azure.com/d365community/idea/ce829a4b-7981-ed11-a81b-000d3ae5ae95. Hopefully it gets picked up.

trevonmckay avatar Dec 21 '22 21:12 trevonmckay

This is ridiculous -- You require contributor access to execute a function -- how does this make any sense??

MIcrosoft please document what Test+Develop blade requires. Also please have a usability expert actually work on azure functions this is a hostile platform to devs and ops engineers. I was able to deploy and terraform a lambda function in less then a day now i am going on 12 days dealing with things that are not documented and having to reverse engineer things.

Seriously this is not a well thought out product its a me to competitor to lambda and its a poor one at that.

  1. It should not require storage to deploy a function -- also files and object come on.
  2. Please on the deploy docs please put up what is required for the storage accounts including settings
  3. Please for the love of sam please figure out a cohesive stratgy on cloud -- alot of people are forced to use azure they dont want to use it. Mostly because things are half baked in a lot of categories. (App Service [Failed Deploys], Azure Functions [not true serverless option] i could go on)
  4. Errors on functions should be useful not return something that has no googleable terms.
  5. Document required perms for Dev+Test blade i mean this should be a basic ask. Or create a perm set that can be deployed like Azure Function Executor -- having this damn thing spin or randomly work is uber frustrating.

mxrss2 avatar May 08 '24 17:05 mxrss2

I guess this will solve your problem... you can add the below permissions to a custom role as you require.

microsoft.web/sites/functions/action microsoft.web/sites/functions/delete microsoft.web/sites/functions/listsecrets/action microsoft.web/sites/functions/read microsoft.web/sites/functions/write microsoft.web/sites/functions/masterkey/read microsoft.web/sites/functions/token/read

PS Cmd : Get-AzProviderOperation "Microsoft.web/sites/functions/*" | FT

When I tried this, the user still got permission error when trying to view/run the function code. What I ended up doing that cleared the error was checked the select all permissions for microsoft.web module when creating the custom role...which I guess is slightly better than contributor. Unfortunately, don't have time to go through all the permissions one by one to see which one actually did it...

ELL231 avatar Jul 24 '24 17:07 ELL231