How can I, using the Azure Python API, create a full set of credentials that can later be used to start and deallocate all VMs in a named resource group, without any other
Your need the azure-graphrbac
package to create a Service Principal:
The closer to a sample might be this unittest:
For role and permissions, you need azure-mgmt-authorization
:
Best sample for this one, is probably the sub-part of this sample:
"msi_identity" is a synonym of "service principal" in your context.
Note that all of this is supported by the CLI v2.0:
It might be interested to test the CLI in --debug
mode and sniffing in the code repo at the same time:
(full disclosure, I work at MS in the Azure SDK for Python team)