How to automatically assign System-assigned managed identity to DevTest Lab Windows VM

Sameer Youssef 1 Reputation point
2022-08-11T02:21:46.153+00:00

Summary: Azure Marketplace VM image created by DevTest Labs did not get assigned the system-assigned managed identity upon creation

Steps:

  • Verify that DevTest Lab Configuration and policies | Identity (Preview) page is on (default setting anyway)
  • Create VM within DevTest portal using base Free SQL Server License: SQL Server 2019 Developer on Windows Server 2022
  • Verify identities on the VM via CLI az vm identity show -n vm07 -g LAB0123456791000

Result:

  • No identities returned

Desired:

  • I'd like the system-assigned managed identity to be there from the get go. That way I can use command such as AzCopy to get data from my blob (in the same subscription/resource group as the VM) without having to login with my personal credentials.

Workaround:

  • az login and go through webpage authentication using my personal credentials -> urgh
  • Figure out which vm/scope to use
  • Run az vm identity assign --role Reader --identities [system] -n vm07 -g LAB0123456791000--scope /subscriptions/123-234-3456-567 to assign the identity -> pain
Azure DevTest Labs
Azure DevTest Labs
An Azure service that is used for provisioning development and test environments.
259 questions
{count} votes

2 answers

Sort by: Most helpful
  1. srbhatta-MSFT 8,546 Reputation points Microsoft Employee
    2022-08-16T14:31:42.247+00:00

    Hello @Sameer Youssef ,
    Welcome to Microsoft QnA.
    Are you seeing something like this on the Portal under Identity of your DevTest Lab?

    231663-2022-08-16-19-53-05-clipboard.png

    1 person found this answer helpful.

  2. David Broggy 5,686 Reputation points MVP
    2022-08-11T03:50:32.08+00:00

    Hi Sameer,
    Have you seen this preview feature for automatically assigning managed identities using Azure Policy?
    how-to-assign-managed-identity-via-azure-policy