Setting UAMI and Primary Identity Managed Instance timeout

Julie 40 Reputation points
2025-10-28T12:59:30.4633333+00:00

Hello,

I want to set identites after provisioning Azure SQL Managed Instance with Azure Powershell.

First I set my automation-umi and a unique umi per instance to UAMI, then I set primary to the automation-umi. The automation-umi has Directory Reader Role.

$AllIdentities = @($AutomationUserManagedIdentityId, $InstanceUserAssignedIdentityId)      

Set-AzSqlInstance -Name $InstanceName `        
-ResourceGroupName $ResourceGroup `         
-IdentityType UserAssigned `         
-UserAssignedIdentityId $AllIdentities `         
-AssignIdentity `         
-Force      

Set-AzSqlInstance -Name $InstanceName `         
-ResourceGroupName $ResourceGroup `         
-PrimaryUserAssignedIdentityId $AutomationUserManagedIdentity.ClientId `         
-AssignIdentity `         
-Force 

My problem is that it times out when setting primary identity.

WARNING: Failed to terminate process: 1 error occurred:

* failed to send Ctrl-Break event to process being terminated: The handle is invalid.

Do you have any advice? The timeout happens after 1 hour

I have also tried to to it in one command, but it still times out. But when I do this I see the instance is set to currently updating. How long can you expect this would take? :)


Set-AzSqlInstance -Name $InstanceName `        
-ResourceGroupName $ResourceGroup `         
-IdentityType UserAssigned `         
-UserAssignedIdentityId $AllIdentities `    
-PrimaryUserAssignedIdentityId $AutomationUserManagedIdentity.ClientId `       
-AssignIdentity `         
-Force  
Azure SQL Database
{count} votes

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.