0

How can i find the app, whose credentials were used to launch a vm in azure. I am able to use the compute client to get admin_username attached to a VM but it does not solve my use case as a user can give any username while launching it.

compute_client = ComputeManagementClient(credentials, subscription_id)

vm_details = compute_client.virtual_machines.get(resource_group_name= <resource_group>, vm_name=<vm_name>, expand='instanceView')

username = vm_details.os_profile.admin_username

Is the app_name stored as a vm property anywhere that can be accessed via azure-sdk for python?

TheShobhit147
  • 125
  • 1
  • 1
  • 7

1 Answers1

0

First, please clarify "launch". Do you mean initial deployment, or starting an already existing VM which was off? Or both :)?

I do believe that this information is not part of the VM, but will be considered an event of ARM. Then, this will be available part of the Activity Log: https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-overview-activity-logs

Activity Log is available in the Monitor SDK: https://learn.microsoft.com/en-us/python/api/overview/azure/monitoring?view=azure-python

If you want to test this quickly, try the CLI: https://learn.microsoft.com/en-us/cli/azure/monitor/activity-log?view=azure-cli-latest#az-monitor-activity-log-list

Since this CLI is using the same SDK, if you find your information with the CLI this means you can definitely get it with SDK

(I work at MS in the Python team, but not in the VM or Monitor team, it's why I start my post with "believe", but I really think it's accurate based on my knowledge of Azure)

Laurent Mazuel
  • 3,422
  • 13
  • 27