-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
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
Replication delays: Not a valid reference update error UserAssignedIdentity and Microsoft.Graph/[email protected] #193
Comments
@Anttarax - during deployment, what are you setting the I'll have to check, but the "Not a valid reference" message can apply to any of the properties of the I'm not sure I follow a lot of the information, especially: Can you shed some more light on this please? |
@dkershaw10 No, I dont providing these on the cmd line. But you should because its a simple way to test it. I completely automated the creation of Appregs. I use all the Bicep Graph resources, a bicepparam contains all Appregs in an array and everything is generated. I can share the complete code, but it's very long and it would take you several hours/days to analyze it. Just use a valid AppServicePrincipal and ApproleId, believe me the values are good, as I generate more than 100 Appregs with this code every day. Now the code has only been extended by creating the UserAssignedIdentity (and role assign to the UserAssignedIdentity). System Assigned Managed Identity and Appreg role to Appreg work correctly. |
@dkershaw10 Here you are. A very simple code. Just replace the values of appRoleId and AppServicePrincipal to your own Appreg. You will definitely get an error. The scope and ResourceGroup that I mentioned earlier are not interesting, you will get an error anyway with or without any module scope (at first run, when userAssignedIdentity is not exist and creating.
Output: Not a valid reference update. Graph client request id: f26c6d30-fecd-46c0-9b50-c66ce2571bdd. Graph request timestamp: 2024-11-19T04:07:25Z."}}"}]}} |
Interesting. I have a similar script that I tried (below). It completes successfully when I deploy. extension graphv1_0
// TEMPLATE OVERVIEW: Creates a MI as a client service, registers a resource app which
// defines an app role, and then creates a resource app SP.
// Finally assign the app role (on the resource app SP) to the MI
param location string = resourceGroup().location
param deployDate string = '2024-11-19'
param clientAppName string = 'miService-${deployDate}'
param resourceName string = 'resourceServiceName-${deployDate}'
@description('Id of the application role to add to the resource app')
var appRoleName = 'ResourceAppData.Read.All'
var appRoleId = guid(resourceName, appRoleName)
// create a managed identity for the client service
resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: 'mi-${uniqueString(clientAppName,location)}'
location: location
}
// create resource app
resource resourceApp 'Microsoft.Graph/[email protected]' = {
uniqueName: resourceName
displayName: resourceName
appRoles: [
{
id: appRoleId
allowedMemberTypes: [ 'User', 'Application' ]
description: 'Read access to resource app data'
displayName: appRoleName
value: appRoleName
isEnabled: true
}
]
}
// Create resource SP
resource resourceSp 'Microsoft.Graph/[email protected]' = {
appId: resourceApp.appId
}
// Assign app role (from resource app) to MI
resource appRoleAssignment 'Microsoft.Graph/[email protected]' = {
principalId: managedIdentity.properties.principalId
resourceId: resourceSp.id
appRoleId: appRoleId
}
output clientSpId string = managedIdentity.properties.principalId
output resourceSpId string = resourceSp.id
output appRoleId string = appRoleId |
I managed to reproduce your error, but only once, having tried > 10 times with the following steps. Repro steps
Expected Actual (when it failed) Likely cause @Anttarax - if you redeploy the same template file a little later, is the redeployment successful? cc: @eketo-msft |
@dkershaw10 |
@dkershaw10 most likely it is the read replica thing. There is the same issue when creating system/user assigned identities and assigning RBAC roles (role assignments) to them. To overcome this role Assignments API https://learn.microsoft.com/en-us/azure/templates/microsoft.authorization/roleassignments?pivots=deployment-language-bicep has the parameter principalType which when provided value ServicePrincipal it does not check if the identity exists, it just assigns the permissions. Most likely the team behind role assignments knows the inner works details. Of course not suggesting that the same thing for role assignments will work or you have to implement it just mentioning that similar issue exists with other RPs. |
@Anttarax - All my "re-runs" were with a new user-assigned MI creation. @slavizh - yeah maybe the Azure role assignment has some special treatment here (could be because it doesn't want to call out to Entra to check, for perf reasons - who knows :)). Anyways, little we can do about the inner workings of the Entra system for app role assignment. @eketo-msft what do you think? |
Any news? @dkershaw10 |
I confirmed the issue was replication latency. The referenced object (MSI backing service principal in Entra) was not available yet. For appRoleAssignedTo we can consider adding a longer timeout/retry policy since we know there is likely some cross-over from Azure provisioning the resource. From what I can tell based on the few repro's here the SP is being created in Entra within a minute of the failed request, so if we consider replication time it should still only be a few minutes to retry. Let's discuss with the engineering team and see what we can come up with to alleviate the issue. |
@eketo-msft I think we need to consider all cross-over scenarios where MSIs might be used, for longer timeout/retry policy:
|
I want to create UserAssignedIdentity, After that I want to Assign an Appreg role to the newly created (service principal of) UserAssignedIdentity.
The UserAssignedIdentity created successfully, but "Microsoft.Graph/[email protected]" thinks that userAssignedIdentity.properties.principalId is invalid, but not.
If I run second time, The deployment success, but first time, when the UserAssignedIdentity creating, I get this error message.
Error message: Not a valid reference update. Graph client request id: 370e13eb-3387-4e5a-b2b6-5f77c357b5dc. Graph request timestamp: 2024-11-18T00:13:49Z.
(Code: BadRequest)
Calling userAssignedIdentities.bicep:
userAssignedIdentities.bicep:
The text was updated successfully, but these errors were encountered: