Salesforce , Python , SQL , & other ways to put your data where you need it

Need event music 🎸, azure rbac role assignment faq.

03 Feb 2024 🔖 security tutorial 💬 EN

Table of Contents

The 3 components of an azure rbac role assignment, create an azure rbac role assignment, target scopes, source principal identities, combining several azure rbac role assignments to fulfill a task.

Below are a few frequently asked questions about Azure RBAC Role Assignments.

Many thanks to colleagues who helped me a lot with editing the wording when I wrote a similar document for internal training.

What is an Azure RBAC Role Assignment?

An Azure RBAC Role Assignment , not to be confused with an Entra RBAC Role Assignment , grants a given identity (that is, one that exists within Microsoft Entra ID) permission to perform specific types of actions against a specific “scope” of Azure resource(s).

In the model of access control where authentication (“proving a nonhuman is who it says it is”) and authorization (“proving a given, authenticated nonhuman is permitted to do what it is trying to do”) , an Azure RBAC Role Assignment helps solve problems related to authorization . 🔐

Microsoft Entra ID , or “Entra” for short, is the new name for what was known as “Azure Active Directory” or “AAD.”

An Azure RBAC Role Assignment is a named Azure resource whose purpose is to describe a junction of three other Azure or Entra resource IDs:

  • An  Azure RBAC “role”   (whether “built-in” and maintained by Microsoft or “custom” and maintained by your company) that authorizes actions such as “write files to Azure Blob Storage.”
  • (Often simply set to “/” to represent the entire Entra tenant.)
  • Usually, the “principal” with Azure RBAC would represent a non-human.
  • Protecting the human’s Azure RBAC Role Assignment with Entra Privileged Identity Management (“PIM”) is an excellent practice in this case.
  • Consult with colleagues before requesting resource locks, because  locking resources may impede productivity in unexpected ways .
  • Also note that if you are having trouble performing actions you expected to be able to perform, given your existing Azure RBAC Role Assignments, check if existing resource locks might be the obstacle.

See “ Assign Azure roles ” on Microsoft Learn.

In a corporate environment, you might not be allowed to do it yourself. Hopefully, your help desk ticketing system has a ticket type that you can open to request that an Azure RBAC Role Assignment be created/edited/deleted on your behalf.

Best practices

Follow the principle of least privilege when requesting the creation of Azure RBAC Role Assignments when choosing all 3 components (role, target scope, and principal) .

When in doubt, create more role assignments, not broader Role Assignments.

Carefully look through Microsoft’s “built-in”  Azure RBAC roles  to find the least-powerful role that can perform a necessary task. For example:

  • “Website Contributor”  instead of the more powerful “Contributor” for deployment automations that need to deploy code onto Azure App Service, Azure Static Web Apps, Azure Functions, etc.
  • “Data Factory Contributor”  instead of the more powerful “Contributor” for deployment automations that need to deploy Azure Data Factory configuration from a “lower” nonproduction environment into a “higher” nonproduction or production environment.
  • “Storage Blob Data Reader”  instead of the more powerful “Reader” for Azure resources, deployment automations, or humans that need to read files out of Azure Blob Storage resources.
  • “Storage Blob Data Contributor”  instead of the more powerful “Contributor” for Azure resources, deployment automations, or humans that need to perform “write” operations against Azure Blob Storage resources.

Once an appropriately capable Azure RBAC role has been selected, it can be assigned to work  against  the following scopes in Azure:

  • Preferred when resources are stable.
  • As long as capabilities are tightly scoped – e.g. “Website Contributor” – this might provide a good balance between safety and convenience if a resource group encapsulates a single workload where appropriate target Azure resources – such as Azure Functions – are constantly being added and/or removed, and waiting for RBAC role assignment against each new function would critically impede productivity.
  • With a slow rate of change, however, individual resource-by-resource assignment may still be preferred for the comfort of knowing explicitly which Azure resources are targets of which Entra identities’ capabilities, rather than guessing based on each RBAC role’s documentation.
  • Questions about infosec tradeoffs between the context of “least privilege” and “ease of maintenance” / “governance?” Colleagues helping you design your solution, and staff on your company’s infosec team, are excellent resources for striking the correct balance amongst various infosec concerns.
  • By default, avoid this. “Subscription” is likely far too broad for common corporate approaches to grouping Azure resources .

Once an appropriately capable RBAC role and narrow target scope has been chosen, the assignment must be attached to a specific Entra identity. Examples include:

  • A single Azure resource’s  System-Assigned Managed Identity (“SMI”)
  • (Only when SMI is not available, and preferably using Federated Identity Credentials to log into it over OIDC if being used with Azure DevOps Pipelines or GitHub Actions code deployment automations.)
  • (Either way, preferably only allowed while privileges are elevated through PIM.)

To adhere to the security principle of least privilege, more than one Azure RBAC Role Assignment may need to be created to fulfill the permissions requirements of a given workload.

For example, a workload’s design may require the creation of:

  • A “ Website Contributor ” Azure RBAC Role Assignment allowing the  Entra App Registration representing a code deployment automation  to deploy code onto a  nonproduction Azure App Service  resource.
  • A “ Storage Blob Data Contributor ” Azure RBAC Role Assignment allowing the  SMI of a nonproduction Azure App Service  resource to read and write against a  nonproduction Storage Blob’s  files.
  • A “ Storage Blob Data Contributor ” Azure RBAC Role Assignment allowing the  Entra group ID representing humans in a certain department  to manually read and write a  nonproduction Storage Blob’s  files.
  • 3 more  Azure RBAC Role Assignments  as listed above  but  scoped for production target resources .
  • Top of Page

sql role assignment name must be a guid

Defining RBAC Role Assignments in ARM Templates

It’s no secret I’m a big fan of Azure Resource Manager (ARM) templates. Getting started with ARM templates is hard, but well worth the effort, and make it significantly easier to have reproduceable, consistent deployments of your Azure resources.

One thing that I had been feeling left out, however, was being able to assign permissions to Azure resources during creation. Azure’s Role-based Access Control (RBAC) mechanism is a powerful way to control who can manage and access your resources, and having to do this through scripting was possible, but cumbersome at times.

A few days ago, I realized that you can actually create RBAC role assignments through ARM templates just like any other resource. This capability is not new by any means, I just had missed it before!

Creating an assignment

To create an assignment, you need the following information:

  • The ID of the role you want to assign. This is a long string that contains the subscription id and the role identifier (both GUIDs).
  • The object ID of the user/group/service principal you want to grant access to.
  • The scope at which you want to assign the role, which is going to be either a subscription, resource group, or resource id.

Here’s an example of creating such an assignment:

Here we grant the members of an Azure Active Directory group the Monitoring Contributor built-in role to the resource group the template is deployed to.

Also interesting here is that you don’t need to specify a location property in the resource.

Some gotchas

There are a couple of things to watch out for when doing this.

The first one is that to assign a role, you need the objectId of the AAD user/group/principal, rather than the name. This is cumbersome because there’s no way to resolve these within the ARM template itself, so you’ll always need to pass these as input parameters.

A more significant issue, however, is the name of the roleAssignment resource, which needs to be a unique GUID.

This is a problem if, for example, you’re assigning role permissions at the resource group or individual resource level, rather than globally at the subscription.

For example, in my case I was creating a template that would be used to deploy multiple copies of the same resources into different resource groups within the same subscription.

If the GUID that defines the role assignment name is hardcoded in the template, then each time I ran the template, the scope of the role assignment would get overwritten with the id of the last resource group it was deployed to. Clearly, this is undesirable.

What we need then, is a way to ensure that each deployment to a different resource group uses a different GUID for the role assignment, but at the same time, ensure that the same one is used when deploying to the same resource group.

Clearly, providing the assignment GUID as a parameter is an easy workaround, but very cumbersome.

A better workaround comes from the guid function! It takes one or more strings that are used to calculate a hash, very much like the uniquestring function; only this one generates a string in GUID format instead.

By using the guid function with the resource group id and some other consistent stuff as input, we can solve our problem in an elegant way:

  • Azure (41) ,
  • Security (2)

sql role assignment name must be a guid

Tomas Restrepo

Software developer located in Colombia.

  • ← Previous
  • Next →

Jason Masten

A personal brain dump of information technology problems & solutions, azure deployment error “tenant id, application id, principal id, and scope are not allowed to be updated.”.

When deploying a role assignment using an ARM template, you receive the error below:

Update your role assignment name (aka GUID) to a value that hasn’t been used previously to deploy a role assignment.

Explanation

Recently I was testing out some code and it was re-used from another solution. When I went to deploy the code, in the same subscription, I received the following error: “Tenant ID, application ID, principal ID, and scope are not allowed to be updated.” The code in question contained a role assignment resource with a static GUID for the name. After testing and isolating the code, I realized the issue was the name of the role assignment resource.

Now, like me, you may make the mistake of using the “newGuid” function to name your role assignments. What could go wrong? The name is now unique now, right? Well each time you deploy your ARM template, a new GUID is created for the resource. That doesn’t work. Once you create a role assignment with a specific GUID, any updates or redeployments will require the same name, aka GUID.

In steps the “guid” function. This function uses a hash to create the GUID based on input that is provided. So, for my scenario, I provided the name of my WVD application group, which is unique across my subscription, and that guaranteed my GUID will be unique yet consistent every time I deploy this ARM template. This is the best practice for creating role assignments with ARM templates. Find a value that is unique and won’t be used elsewhere so your deployments will be idempotent.

Share this:

7 thoughts on “ azure deployment error “tenant id, application id, principal id, and scope are not allowed to be updated.” ”.

Add Comment

How do you implement the newGuid function I had read the documantation but is not clear for me… https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-functions-string#newguid

Hi Karen, use the “guid” function, not the “newGuid” function. “guid” is idempotent and “newGuid” is not. That’s important so you can redeploy your solution if there is an error or update to the template. If you don’t care about idempotency, per the documentation you can use the “newGuid” function within an expression for the default value of a parameter. Like so: { “$schema”: “https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#”, “contentVersion”: “1.0.0.0”, “parameters”: { “guidValue”: { “type”: “string”, “defaultValue”: “[newGuid()]” } }, “resources”: [ ], “outputs”: { “guidOutput”: { “type”: “string”, “value”: “[parameters(‘guidValue’)]” } } }

Hi Jason, I’ experiencing the same problem after I redeployed my template. the error is : “details”:[{“code”:”BadRequest”,”message”:”{\r\n \”error\”: {\r\n \”code\”: \”RoleAssignmentUpdateNotPermitted\”,\r\n \”message\”: \”Tenant ID, application ID, principal ID, and scope are not allowed to be updated.\”\r\n }\r\n}”},{“code”:”BadRequest”

I checked my template and I’m using guid function : { “type”: “Microsoft.Authorization/roleAssignments”, “apiVersion”: “2020-04-01-preview”, “name”: “[guid(‘storageBlobRoleAssignmentName’, parameters(‘storageAccountName’))]”, “dependsOn”: [ “[variables(‘eventGridDeploymentName’)]”, “[resourceId(‘Microsoft.Web/sites’, parameters(‘functionAppName’))]” ], “properties”: { “roleDefinitionId”: “[variables(‘storageBlobDataContributor’)]”, “principalId”: “[reference(resourceId(‘Microsoft.Web/sites’, parameters(‘functionAppName’)),’2019-08-01′, ‘full’).identity.principalId]”, “principalType”: “ServicePrincipal” }, “scope”: “[concat(‘Microsoft.Storage/storageAccounts’, ‘/’, parameters(‘storageAccountName’))]” },

any suggestion how to fix this error?

Al Chab, that can happen if you have an orphaned role assignment. I would validate the RBAC assignments at that scope. Delete any that that are missing the principal info.

I have a problem when assigning roles to a subscription. I have a function that set owner to a subscription. I In some subscriptions it works and in others I get the following error:

“` { “error”: { “code”: “RoleAssignmentUpdateNotPermitted”, “message”: “Tenant ID, application ID, principal ID, and scope are not allowed to be updated.” } } “`

I could not find a reason why this is happening. I using msal library in javascript.

my request is:

“` headers: { Authorization: `Bearer ${token}`, ‘Content-Type’: ‘application/json’, }

url: https://management.azure.com/subscriptions/ {subId}/providers/Microsoft.Authorization/roleAssignments/{roleIdOfOwner}?api-version=’2017-05-01′

body: { properties: { roleDefinitionId: subscriptions/{subId}/providers/Microsoft.Authorization/roleDefinitions/{roleIdOfOwner}, principalId: {principalId of the user} }

Dan, it looks like you are making a REST API call. Here is the reference for that: https://docs.microsoft.com/en-us/azure/role-based-access-control/role-assignments-rest . In the URL for the REST API call, the GUID for the “roleAssignmentId” should be unique for each assignment per scope, principal, and role. That’s referenced in step 2 in the URL I provided above. If an assignment has been orphaned, the principal has been deleted but not the assignment or scope, then you should clean those up.

This issue puzzled me as I was using a guid, but is was based on the SP so when used again it failed..but your fix helped. Just wanted you to know I appreciate you!! Thank you

Leave a comment Cancel reply

' src=

  • Already have a WordPress.com account? Log in now.
  • Subscribe Subscribed
  • Copy shortlink
  • Report this content
  • View post in Reader
  • Manage subscriptions
  • Collapse this bar

Navigation Menu

Search code, repositories, users, issues, pull requests..., provide feedback.

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly.

To see all available qualifiers, see our documentation .

  • Notifications You must be signed in to change notification settings

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-AzRoleAssignment "InvalidPrincipalId" "The Principal ID 'User' is not valid. Principal ID must be a GUID." #16627

@BethanyZhou

brwilkinson commented Dec 13, 2021 • edited Loading

When using New-AzRoleAssignment with -SignInName the following exception occurs

AZ.Resources 5.1.0

-ResourceGroupName ACU1-BRW-APP-RG-D1 -SignInName user@domain.com -RoleDefinitionName Reader Body: { "error": { "code": "InvalidPrincipalId", "message": "The Principal ID 'User' is not valid. Principal ID must be a GUID." } }

The following -ObjectId works as expected, also AZ.Resources 4.4.1 works as expected

-ResourceGroupName ACU1-BRW-APP-RG-D1 -ObjectId be00b5cd-0d02-4824-b221-d30617597152 -RoleDefinitionName Reader -ResourceGroupName ACU1-BRW-APP-RG-D1 -SignInName user123@contoso.com -RoleDefinitionName Reader DEBUG: 3:12:43 PM - NewAzureRoleAssignmentCommand begin processing with ParameterSet 'ResourceGroupWithSignInNameParameterSet'. DEBUG: 3:12:43 PM - using account id '[email protected]'... WARNING: We have migrated the API calls for this cmdlet from Azure Active Directory Graph to Microsoft Graph. Visit https://go.contoso.com/fwlink/?linkid=2181475 for any permission issues. DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47' DEBUG: 3:12:43 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'72f988bf-86f1-41af-91ab-2d7cd011db47', Scopes:'https://graph.contoso.com//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[email protected]' DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://graph.contoso.com//.default ] ParentRequestId: DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Azure region was not configured or could not be discovered. Not using a regional authority. DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43] Found 1 cache accounts and 0 broker accounts DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43] Returning 1 accounts DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] MSAL MSAL.NetCore with assembly version '4.30.1.0'. CorrelationId(7081dca6-c787-4770-8bb2-79c6cfb01bb7) DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === AcquireTokenSilent Parameters === DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] LoginHint provided: False DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Account provided: True DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] ForceRefresh: False DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === Request Data === Authority Provided? - True Scopes - https://graph.contoso.com//.default Extra Query Params Keys (space separated) - ApiId - AcquireTokenSilent IsConfidentialClient - False SendX5C - False LoginHint ? False IsBrokerConfigured - False HomeAccountId - False CorrelationId - 7081dca6-c787-4770-8bb2-79c6cfb01bb7 DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === Token Acquisition (SilentRequest) started: Authority Host: login.microsoftonline.com DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Azure region was not configured or could not be discovered. Not using a regional authority. DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Access token is not expired. Returning the found cache entry. [Current time (12/13/2021 23:12:43) - Expiration Time (12/14/2021 22:20:56 +00:00) - Extended Expiration Time (12/14/2021 22:20:56 +00:00)] DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Returning access token found in cache. RefreshOn exists ? True DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Fetched access token from host login.microsoftonline.com. DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 12/14/2021 22:20:56 +00:00 and Scopes email openid profile https://graph.contoso.com//AuditLog.Read.All https://graph.contoso.com//Directory.AccessAsUser.All https://graph.contoso.com//.default DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://graph.contoso.com//.default ] ParentRequestId: ExpiresOn: 2021-12-14T22:20:56.0000000+00:00 DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: '[email protected]' DEBUG: [Common.Authentication]: Authenticating using Account: '[email protected]', environment: 'AzureCloud', tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47' DEBUG: 3:12:43 PM - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'72f988bf-86f1-41af-91ab-2d7cd011db47', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'[email protected]' DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Azure region was not configured or could not be discovered. Not using a regional authority. DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43] Found 1 cache accounts and 0 broker accounts DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43] Returning 1 accounts DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] MSAL MSAL.NetCore with assembly version '4.30.1.0'. CorrelationId(c91d6159-cb05-4a9e-a6c2-84ab1652948e) DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === AcquireTokenSilent Parameters === DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] LoginHint provided: False DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Account provided: True DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] ForceRefresh: False DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === Request Data === Authority Provided? - True Scopes - https://management.core.windows.net//.default Extra Query Params Keys (space separated) - ApiId - AcquireTokenSilent IsConfidentialClient - False SendX5C - False LoginHint ? False IsBrokerConfigured - False HomeAccountId - False CorrelationId - c91d6159-cb05-4a9e-a6c2-84ab1652948e DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === Token Acquisition (SilentRequest) started: Authority Host: login.microsoftonline.com DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Azure region was not configured or could not be discovered. Not using a regional authority. DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Access token is not expired. Returning the found cache entry. [Current time (12/13/2021 23:12:43) - Expiration Time (12/14/2021 00:23:37 +00:00) - Extended Expiration Time (12/14/2021 00:23:37 +00:00)] DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Returning access token found in cache. RefreshOn exists ? False DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] Fetched access token from host login.microsoftonline.com. DEBUG: (False) MSAL 4.30.1.0 MSAL.NetCore Microsoft Windows 10.0.22523 [12/13/2021 23:12:43 - ] === Token Acquisition finished successfully. An access token was returned with Expiration Time: 12/14/2021 00:23:37 +00:00 and Scopes https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2021-12-14T00:23:37.0000000+00:00 DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: '[email protected]' DEBUG: ============================ HTTP REQUEST ============================ HTTP Method: GET Absolute Uri: https://graph.contoso.com/v1.0/users?$filter=userPrincipalName eq %27user123%40contoso.com%27 Headers: x-ms-client-request-id : 8f496da2-4d8a-46b4-937b-ec86ef64d8f1 Accept-Language : en-US ConsistencyLevel : eventual Body: DEBUG: ============================ HTTP RESPONSE ============================ Status Code: OK Headers: Cache-Control : no-cache Transfer-Encoding : chunked Strict-Transport-Security : max-age=31536000 request-id : ebe30357-3202-4ca5-8aeb-6b72e543723c client-request-id : ebe30357-3202-4ca5-8aeb-6b72e543723c x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West US 2","Slice":"E","Ring":"1","ScaleUnit":"000","RoleInstance":"CO1PEPF00000D12"}} x-ms-resource-unit : 2 OData-Version : 4.0 Date : Mon, 13 Dec 2021 23:12:44 GMT Body: { "@odata.context": "https://graph.contoso.com/v1.0/$metadata#users", "value": [ { REDACTED } ] } DEBUG: ============================ HTTP REQUEST ============================ HTTP Method: GET Absolute Uri: https://management.azure.com//subscriptions/b8f402aa-20f7-4888-b45c-3cf086dad9c3/resourceGroups/ACU1-BRW-APP-RG-D1/providers/Microsoft.Authorization/roleDefinitions?$filter=roleName eq 'Reader'&api-version=2018-01-01-preview Headers: x-ms-client-request-id : 8f496da2-4d8a-46b4-937b-ec86ef64d8f1 Accept-Language : en-US Body: DEBUG: ============================ HTTP RESPONSE ============================ Status Code: OK Headers: Cache-Control : no-cache Pragma : no-cache x-ms-request-id : 5d9ec141-779e-413a-af28-1b944cfe6b6b X-Content-Type-Options : nosniff Strict-Transport-Security : max-age=31536000; includeSubDomains Set-Cookie : x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly x-ms-ratelimit-remaining-subscription-reads: 11997 x-ms-correlation-request-id : a6a01f62-ecb7-4750-a964-ba7e6d7b2860 x-ms-routing-request-id : WESTUS2:20211213T231244Z:a6a01f62-ecb7-4750-a964-ba7e6d7b2860 Date : Mon, 13 Dec 2021 23:12:44 GMT Body: { "value": [ { "properties": { "roleName": "Reader", "type": "BuiltInRole", "description": "View all resources, but does not allow you to make any changes.", "assignableScopes": [ "/" ], "permissions": [ { "actions": [ "*/read" ], "notActions": [], "dataActions": [], "notDataActions": [] } ], "createdOn": "2015-02-02T21:55:09.8806423Z", "updatedOn": "2021-11-11T20:13:47.8628684Z", "createdBy": null, "updatedBy": null }, "id": "/subscriptions/b8f402aa-20f7-4888-b45c-3cf086dad9c3/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", "type": "Microsoft.Authorization/roleDefinitions", "name": "acdd72a7-3385-48ef-bd42-f606fba81ae7" } ] } DEBUG: ============================ HTTP REQUEST ============================ HTTP Method: PUT Absolute Uri: https://management.azure.com//subscriptions/b8f402aa-20f7-4888-b45c-3cf086dad9c3/resourceGroups/ACU1-BRW-APP-RG-D1/providers/Microsoft.Authorization/roleAssignments/a7e86d59-f833-4d41-b3ed-10f3c12e0ba0?api-version=2020-08-01-preview Headers: x-ms-client-request-id : 8f496da2-4d8a-46b4-937b-ec86ef64d8f1 Accept-Language : en-US Body: { "properties": { "roleDefinitionId": "/subscriptions/b8f402aa-20f7-4888-b45c-3cf086dad9c3/resourceGroups/ACU1-BRW-APP-RG-D1/providers/Microsoft.Authorization/roleDefinitions/acdd72a7-3385-48ef-bd42-f606fba81ae7", "principalId": "User", "principalType": "User" } } DEBUG: ============================ HTTP RESPONSE ============================ Status Code: BadRequest Headers: Cache-Control : no-cache Pragma : no-cache x-ms-request-id : c02454ec-9ab7-4c29-bc68-c49442edc946 X-Content-Type-Options : nosniff Strict-Transport-Security : max-age=31536000; includeSubDomains Set-Cookie : x-ms-gateway-slice=Production; path=/; secure; samesite=none; httponly x-ms-ratelimit-remaining-subscription-writes: 1198 x-ms-correlation-request-id : 46cefcd7-facf-49da-b80d-982c1154e9d2 x-ms-routing-request-id : WESTUS2:20211213T231245Z:46cefcd7-facf-49da-b80d-982c1154e9d2 Date : Mon, 13 Dec 2021 23:12:44 GMT Body: { "error": { "code": "InvalidPrincipalId", "message": "The Principal ID 'User' is not valid. Principal ID must be a GUID." } } New-AzRoleAssignment: Operation returned an invalid status code 'BadRequest' DEBUG: AzureQoSEvent: Module: Az.Resources:5.1.0; CommandName: New-AzRoleAssignment; PSVersion: 7.2.0-preview.10; IsSuccess: False; Duration: 00:00:01.2699182; Exception: Operation returned an invalid status code 'BadRequest'; DEBUG: Finish sending metric. DEBUG: 3:12:45 PM - NewAzureRoleAssignmentCommand end processing. Name Value ---- ----- PSVersion 7.2.0-preview.10 PSEdition Core GitCommitId 7.2.0-preview.10 OS Microsoft Windows 10.0.22523 Platform Win32NT PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…} PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1 WSManStackVersion 3.0 az* ModuleType Version PreRelease Name ExportedCommands ---------- ------- ---------- ---- ---------------- Script 2.7.0 Az.Accounts {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…} Script 3.6.1 Az.KeyVault {Add-AzKeyVaultCertificate, Add-AzKeyVaultCertificateContact, Add-AzKeyVaultKey, Add-AzKeyVaultMa… Script 5.1.0 Az.Resources {Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzDenyAssignment, Get-AzDeployment…} Script 3.12.0 Az.Storage Message : Operation returned an invalid status code 'BadRequest' StackTrace : at Microsoft.Azure.Management.Authorization.RoleAssignmentsOperations.CreateWithHttpMessagesAsync(String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, Dictionary`2 customHeaders, CancellationToken cancellationToken) at Microsoft.Azure.Management.Authorization.RoleAssignmentsOperationsExtensions.CreateAsync(IRoleAssignmentsOperations operations, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters, CancellationToken cancellationToken) at Microsoft.Azure.Management.Authorization.RoleAssignmentsOperationsExtensions.Create(IRoleAssignmentsOperations operations, String scope, String roleAssignmentName, RoleAssignmentCreateParameters parameters) at Microsoft.Azure.Commands.Resources.Models.Authorization.AuthorizationClient.CreateRoleAssignment(FilterRoleAssignmentsOptions parameters, Guid roleAssignmentId) at Microsoft.Azure.Commands.Resources.NewAzureRoleAssignmentCommand.ExecuteCmdlet() at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.<>c__3`1.<ExecuteSynchronouslyOrAsJob>b__3_0(T c) at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet, Action`1 executor) at Microsoft.WindowsAzure.Commands.Utilities.Common.CmdletExtensions.ExecuteSynchronouslyOrAsJob[T](T cmdlet) at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord() Exception : Microsoft.Azure.Management.Authorization.Models.ErrorResponseException InvocationInfo : {New-AzRoleAssignment} Line : New-AzRoleAssignment -ResourceGroupName ACU1-BRW-APP-RG-D1 -SignInName user123@contoso.com -RoleDefinitionName Reader Position : At line:1 char:1 + New-AzRoleAssignment -ResourceGroupName ACU1-BRW-APP-RG-D1 -SignInNam … + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ HistoryId : 2 The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.

@brwilkinson

Successfully merging a pull request may close this issue.

@brwilkinson

  • Stack Overflow for Teams Where developers & technologists share private knowledge with coworkers
  • Advertising & Talent Reach devs & technologists worldwide about your product, service or employer brand
  • OverflowAI GenAI features for Teams
  • OverflowAPI Train & fine-tune LLMs
  • Labs The future of collective knowledge sharing
  • About the company Visit the blog

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Get early access and see previews of new features.

Incremental redeployment of an ARM Template with Role Assignments throws an error

If I use Azure Pipelines to do an 'Incremental' 'Resource Group' scoped deployment of an ARM template containing Role Assignments, it seems I can't rerun/redeploy the pipeline without receiving an error on the Role Assignment resource:

This looks like an obvious issue that must have a common workaround? I'm I expected to break-out the Role Assignments into a separate template, and perhaps delete and re-create the role assignments on each deployment?

  • azure-pipelines
  • azure-resource-manager
  • azure-rm-template
  • azure-service-principal

JohnKoz's user avatar

2 Answers 2

Just as you said, this is an obvious issue. For the same scope or resource, you can only assign the same role to a service principal once.

So, there is existing role assignment with the same name that you are trying to create through this template and it ends up giving the error for " RoleAssignmentUpdateNotPermitted ".

To resolve this issue, we need ensure that each deployment to a different resource group uses a different GUID for the role assignment, but at the same time, ensure that the same one is used when deploying to the same resource group.

We could use the guid function! It takes one or more strings that are used to calculate a hash, very much like the uniquestring function; only this one generates a string in GUID format instead:

You could refer the document Defining RBAC Role Assignments in ARM Templates for some more details.

Leo Liu's user avatar

  • 2 Thank you Leo. Just to clarify, in my case I'm deploying the identical arm template to the same resource group. The GUID is hard-coded (for testing) so the name is the same, the role is the same, the resource is the same, etc. And I still get get the above error. Are you saying I should not? –  JohnKoz Commented Feb 15, 2021 at 23:33
  • @JohnKoz, Yes, According to the documentation, for the same scope or resource, you can only assign the same role to a service principal once. –  Leo Liu Commented Feb 16, 2021 at 1:44
  • 1 Thanks Leo. So how would I re-run an existing pipeline without error? The "incremental" deployment mode has ignored ARM Resources if no changes were made. A CI/CD pipeline may run often without change. Should I add a step to my pipeline to delete all role assignments, so that the pipeline can re-create them? If this is the case, the "incremental" nature of a roleAssignment ARM template seems broken? –  JohnKoz Commented Feb 16, 2021 at 22:56
  • FYI, i've done some additional testing and i'm not getting errors now, suggesting it may be possible. Not sure what to believe now, but I'll continue forward. I'll mark this as an answer for the helpfulness (think you). –  JohnKoz Commented Feb 17, 2021 at 12:59
  • I am getting this same error now for Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments I even use the same exact settings from the ARM template and still happens. –  tank104 Commented Sep 21, 2021 at 1:30

You have asked about incremental updates, this troubleshooting article helps some of the way: https://learn.microsoft.com/en-us/azure/role-based-access-control/troubleshooting?tabs=bicep#symptom---arm-template-role-assignment-returns-badrequest-status

But how I understand it, if you are re-creating the role assignment again with the same GUID, it will try and replace the one that is there. This is generally what we want in an incremental update. However, if any of the other 3 parameters (Tenant ID, application ID, principal ID) have changed and you use the same GUID - it will be seen as an update and you will recieve this error.

Tenant ID, application ID, principal ID, and scope are not allowed to be updated. (code: RoleAssignmentUpdateNotPermitted)

As the error states - these properties cannot be changed.

So what if we want a different assignement, e.g. if the PrincipleID has changed for this deployment? Well then we can use a new GUID, it won't be seen as a change and a new roleAssignment will be made. (The previous one would have to be removed by another means).

If however you use a new GUID and the other 3 properties do remain the same, it will be seen as a duplicate role assignment and also throw an error!

So this is why, we should use the GUID() function to create a guid ID that is based off the other 3 parameters. This way in an incremental update, if we are re-deploying the EXACT same roleAssignment, we use the same GUID. And if we are deploying something different (e.g. the PrincipleID has changed) then we would get a new GUID and it would be seen as a new roleAssignment rather than an update.

In the Azure doc above, the example they give is this:

Steve's user avatar

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Sign up or log in

Post as a guest.

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy .

Not the answer you're looking for? Browse other questions tagged azure-pipelines azure-resource-manager azure-rm-template azure-rbac azure-service-principal or ask your own question .

  • The Overflow Blog
  • The evolution of full stack engineers
  • One of the best ways to get value for AI coding tools: generating tests
  • Featured on Meta
  • Bringing clarity to status tag usage on meta sites
  • Join Stack Overflow’s CEO and me for the first Stack IRL Community Event in...
  • Feedback requested: How do you use tag hover descriptions for curating and do...
  • Staging Ground Reviewer Motivation
  • What does a new user need in a homepage experience on Stack Overflow?

Hot Network Questions

  • Inertia Action on Kummer Sheaves
  • Is the white man at the other side of the Joliba river a historically identifiable person?
  • Why does ATSAM3X8E have two separate registers for setting and clearing bits?
  • Is quantum computation effectiveness dependent on EPR non-locality?
  • Do images have propositional content?
  • How much does a ma'ah cost in £/$ in today's world?
  • Unstable plans when two first index columns have NULL values in all rows
  • Remove spaces from the 3rd line onwards in a file on linux
  • Why public key is taken in private key in Kyber KEM?
  • Sitecore headless on local environment experience editor facing issue
  • How to create rounded arrows to highlight inflection points in a TikZ graph?
  • Has anyone returned from space in a different vehicle from the one they went up in? And if so who was the first?
  • How much technological progress could a group of modern people make in a century?
  • Looking for the name of a possibly fictional science fiction TV show
  • Advice how to prevent sin
  • Wrong explanation for why "electron can't exist in the nucleus"?
  • Is it possible for one wing to stall due to icing while the other wing doesn't ice?
  • How cheap would rocket fuel have to be to make Mars colonization feasible (according to Musk)?
  • Circuit that turns two LEDs off/on depending on switch
  • What do these expressions mean in NASA's Steve Stitch's brief Starliner undocking statement?
  • What is vi command package?
  • Does Poincare recurrence show that Gibbs entropy is not strictly increasing?
  • Could they free up a docking port on ISS by undocking the emergency vehicle and letting it float next to the station for a little while
  • Paying a fine when I don't trust the recipient

sql role assignment name must be a guid

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Error when deploying Arm template via console "role definition ID is not in proper GUID format"

I'm trying to deploy an Arm Template that creates a Sysadmin Role with an admin-all policy in my subscription that is linked to a specific Active Directory Group. When I run the template through deployments in the AZ portal, the template is successfully validated, but when I hit the create button to deploy the template it fails.

Here is the error code It's kicking when the deployment fails:

Here is the code section that is failing in the template:

I'm assuming that this is the code string that is causing the error, but not sure what is wrong or how to fix it?

Azure Role-based access control An Azure service that provides fine-grained access management for Azure resources, enabling you to grant users only the rights they need to perform their jobs. 785 questions Sign in to follow Follow

Microsoft Entra ID A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory. 21,298 questions Sign in to follow Follow

@Azure Newb

I wanted to check in and see if you had any other questions or if you were able to resolve this issue?

If you have any other questions, please let me know. Thank you for your time and patience throughout this issue.

If the information helped address your question, please Accept the answer . This will help us and also improve searchability for others in the community who might be researching similar information.

Try "name": "guid()” instead, this way it’ll be a valid GUID and it will also be unique every time you run the deployment.

Hi @Azure Newb ,

The error you're encountering is due to the role definition ID not being in the proper GUID format. In your ARM template, you're using the following line to generate the role definition ID:

"name": "[concat('SystemAdministratorRole-', uniqueString(resourceGroup().id))]",

To fix this issue, you should generate a proper GUID for the role assignment name. You can use the guid() function to create a deterministic GUID based on the scope, principal ID, and role ID. Here's an example from :

Replace the name field in your ARM template with the example above, and make sure to set the appropriate variables for principalId , roleDefinitionId , and principalType . This should resolve the error you're encountering.

Please let me know if you have any questions and I can help you further.

If this answer helps you please mark "Accept Answer" so other users can reference it.

IMAGES

  1. What is a GUID in SQL Server

    sql role assignment name must be a guid

  2. What is a GUID in SQL Server

    sql role assignment name must be a guid

  3. How to generate a Guid in SQL Server?

    sql role assignment name must be a guid

  4. What is a GUID in SQL Server

    sql role assignment name must be a guid

  5. What is a GUID in SQL Server

    sql role assignment name must be a guid

  6. What is a GUID in SQL Server

    sql role assignment name must be a guid

VIDEO

  1. Assignment Name Page Design\simple and easy 💕 #art #drawing #design #artist

  2. Assign predefined / fixed database roles on Microsoft SQL SERVER 2016

  3. Assignment 4 Solution || SQL JOINS || SQL Tutorial || Practice || Dsa TechSimplified

  4. Lecture

  5. Assignment 4 || SQL JOINS || SQL Tutorial || Practice

  6. Lecture

COMMENTS

  1. Azure role assignment name needs to be GUID #121

    Azure role assignment name needs to be GUID · Issue #121

  2. az cosmosdb sql role assignment

    az cosmosdb sql role assignment

  3. Understand Azure role assignments

    A role assignment's resource name must be a globally unique identifier (GUID). Role assignment resource names must be unique within the Microsoft Entra tenant, even if the scope of the role assignment is narrower. Tip. When you create a role assignment by using the Azure portal, Azure PowerShell, or the Azure CLI, the creation process gives the ...

  4. Adding a RBAC role to multiple users using single azure resource via

    InvalidRoleAssignmentId: The role assignment ID 'u4ttmsjymtpe21' is not valid. The role assignment ID must be a GUID. InvalidRoleAssignmentId: The role assignment ID 'u4ttmsjymtpe20' is not valid. The role assignment ID must be a GUID. Instead of passing the [newGuid()] as value to the parameter, you need to pass it as a default value to the ...

  5. Create Azure RBAC resources by using Bicep

    Create Azure RBAC resources by using Bicep

  6. Standard for RBAC Role Assignment names · Azure bicep

    Standard for RBAC Role Assignment names #10539

  7. Support autogenerating RoleAssignment GUID for AzureName #2352

    - Disable defaultAzureName for RoleAssignment. - Add a handcrafted defaultAzureName for RoleAssignment and SQLRoleAssignment which generates a UUID based on Owner.Group + Owner.Kind + Owner.Name + Group + Kind + Namespace + Name. Fixes #2352. * CosmosDB SQL role assignment AzureName generation * Add FAQ entry for RoleAssignments

  8. Azure RBAC Role Assignment FAQ

    The 3 components of an Azure RBAC Role Assignment. An Azure RBAC Role Assignment is a named Azure resource whose purpose is to describe a junction of three other Azure or Entra resource IDs: An Azure RBAC "role" (whether "built-in" and maintained by Microsoft or "custom" and maintained by your company) that authorizes actions such ...

  9. Defining RBAC Role Assignments in ARM Templates

    Defining RBAC Role Assignments in ARM Templates

  10. Azure Deployment Error "Tenant ID, application ID, principal ID, and

    Once you create a role assignment with a specific GUID, any updates or redeployments will require the same name, aka GUID. In steps the "guid" function. This function uses a hash to create the GUID based on input that is provided. So, for my scenario, I provided the name of my WVD application group, which is unique across my subscription ...

  11. az role assignment

    az role assignment

  12. InvalidRoleAssignmentId Error when following FQRID best practice

    Trying several ways to specify a roleDefinitionId property on a RoleAssignment resource, I keep getting: InvalidRoleAssignmentId: The role assignment ID must be a GUID This is a very simplified tem...

  13. Assign Azure roles using Azure Resource Manager templates

    Assign Azure roles using Azure Resource Manager ...

  14. Role assignment name must be a guid? #194

    If I change the above code to use a guid for the RoleAssignmentName, then it works: new RoleAssignment (. name, new RoleAssignmentArgs. { RoleAssignmentName = Guid.NewGuid().ToString(), // <== change here RoleDefinitionId =.

  15. Create a CosmosDB Role Assignment using an ARM Template

    Jul 5, 2021, 7:15 AM. I am trying to create a Cosmos DB Role Assignment using an ARM Template. ALl examples I found are creating the role assignments as a child resource of the cosmos account inside the arm template. Nevertheless, I thought it must be possible to have the role assignment standalone (in my case it does not belong to the database ...

  16. New-AzRoleAssignment "InvalidPrincipalId" "The Principal ID ...

    Principal ID must be a GUID. The following -ObjectId works as expected, also AZ.Resources 4.4.1 works as expected New-AzRoleAssignment - ResourceGroupName ACU1 - BRW - APP - RG - D1 - ObjectId be00b5cd - 0d02 - 4824 - b221 - d30617597152 - RoleDefinitionName Reader

  17. Managed Identity Azure Role Assignments?

    The issue that you are facing is when you deploy the ARM template for first time the identity is recently created that has not yet been fully replicated so you might notice that the security principal (user, group, service principal, or managed identity) is listed as Identity not found with an Unknown type. And when you try to update the same ...

  18. Incremental redeployment of an ARM Template with Role Assignments

    Incremental redeployment of an ARM Template with Role ...

  19. Error when deploying Arm template via console "role definition ID is

    Error when deploying Arm template via console "role ...