通过 shell 或 ansible 在 azure 上创建 vm 实例?

Creating vm instance on azure through shell or ansible?

我想通过我机器上的 ansible/shell 脚本在 Azure 上创建一个 VM 实例。

我找到的方法

  1. 正在我的机器上安装 az cliaz login 并创建实例。

az cli 的问题:通过这种方式我可以创建实例,但我需要无限期的会话登录,除非我注销。如果我注销或系统将我注销,那么我必须使用门户手动登录到 cli,我没有 want.If 有任何使用密钥或密码登录的自动化过程。

任何人都可以建议我如何实现吗?

根据您的要求,您可以使用服务主体登录 Azure CLI 和 ansible。这样就相当于用户名和密码了,不用再用portal登录了。

你可以关注steps via the Azure CLI command to create the service principal and use it to log in. And the ansible steps here.