AbianG
AbianG

Reputation: 33

Azure python SDK run powershell script inside a Virtual Machine

Summary: I'm trying to create a python program to run Powershell scripts in Azure Windows VMs. But I can't find good documentation about which libraries of the SDK I can use.

Detailed: In order to automate certain administrative tasks, a python program should run, authenticate into Azure and then run Powershell scripts in certain Windows VMs. I think I have the auth part thanks to azure.identity, but I can't find any library to interact with a running VM. Sure, lots for creating or modifying a VM in Azure, but nothing to interact with it. Neither in the SDK or in the API browser. I know it can be done with Azure CLI, but id like to use the SDK, if possible at all.

Upvotes: 0

Views: 683

Answers (1)

Satya V
Satya V

Reputation: 4164

My understanding is that you would like to run PowerShell remotely using the Python SDK.

AFAIK, I don't think there is a provision within the Azure Python SDK to run remote PS scripts.

Workaround :

(But please note that this outside the Azure Python SDK.)

You could create Azure Windows WinRM VM template and you could execute ps commands from the Python code using the winrm library like discussed in this thread.

Upvotes: 1

Related Questions