I'm programmatically creating EventGrid Domain's and Topics using the Azure.ResourceManager libraries. I'd like to assign a user assigned identity to the domain as well. I can see that the EventGridDomainData object has an Identity property and that Identity has the UserAssignedIdentities dictionary, but it's unclear to me how to actually add a record to that? I'm guessing there's some other class that inherits from the "UserAssignedIdentity" that I'm not seeing that you cast here or some other utility that can be used to create it.
I haven't found any samples from Microsoft on how to do this either. I've found User Assigned Identity Sample which shows how to get a UserAssignedIdentityResource and UserAssignedIdentityData. The EventGridDomainData class has the Identity property which is of type ManagedServiceIdentity. That has the dictionary which takes as a value a UserAssignedIdentity but the only exposed constructor doesn't take any parameters and the two properties are read-only.
The code to create the domain looks something like this so far:
ArmClient client = new(new DefaultAzureCredential());
var domainToUpdate = new EventGridDomainData(_azureSettings.DefaultLocation)
{
InputSchema = EventGridInputSchema.EventGridSchema,
Identity = new Azure.ResourceManager.Models.ManagedServiceIdentity(managedServiceIdentityType: ManagedServiceIdentityType.UserAssigned)
};
Any ideas?