通过Terraform创建Azure Windows VM [英] Creating a Azure Windows VM through Terraform

查看:127
本文介绍了通过Terraform创建Azure Windows VM的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Azure中,我正在尝试使用Terraform创建Windows VM.我之前使用Template.json文件通过Powershell完成了此操作.现在,我需要接触terraform,这是我的新手.因此,我搜索了一些在Azure中创建VM的示例脚本,并发现

In Azure, I'm trying to create a Windows VM using Terraform. I have done this through Powershell previously using Template.json file. Now I have to do with terraform, which I'm completely new to. So I have searched for some Sample scripts which creates VM in Azure and found this.

在此链接中,有一个示例Terraform脚本来旋转Linux VM.但是我需要从Image旋转Windows VM.我应该在哪里提供图像详细信息.我的完整要求是:

In this link, there is a sample Terraform script to spin a Linux VM. But I need to spin a windows VM from an Image. Where should I give the Image details. My complete requirement is:

  1. 从映像(具有资源ID)创建Windows VM
  2. 我已经创建了资源组,虚拟网络,子网.我只需要传递这些值并创建它们.
  3. 我们已经从门户网站本身定义了子网地址前缀,即Vnet地址空间.因此,我必须再次在脚本中提供还是可以跳过该脚本.
  4. 业务需求是任何VM都不应具有公共IP和DNS名称,因此,如果我删除#Create public IPs"部分,那将不会创建公共IP吗?

用于创建Linux计算机的脚本为此处,我以此为参考.

The script for creating a Linux machine is here, which I'm taking it as reference.

推荐答案

从Terraform的角度来看,Windows VM实际上与Linux VM非常相似.我认为#1的区别是Windows VM需要os_profile_windows_config属性,而Linux VM需要os_profile_linux_config.

From Terraform's perspective, a Windows VM is really quite similar to a Linux VM. The #1 difference in my opinion is that the Windows VM requires a os_profile_windows_config attribute, while the Linux VM needs os_profile_linux_config.

在Microsoft网站上找到的TF代码是一个很好的开始.此外,您可以查看 Terraform Registry .例如,这是用于Linux VM的模块

The TF code you found on the Microsoft site is a fine start. Additionally, you may look in the Terraform Registry. For example, here's a module for a Linux VM.

我强烈建议您通读 VM资源中的所有选项.我知道很多,但是您应该了解自己的选择.

I strongly recommend reading through all of the options in the VM resource. I know it's a lot, but you should understand what choices you have.

最后,没有什么可以替代编写一些代码并对其进行测试了.如果您做错了什么,Terraform和/或Azure API会告诉您,如果不清楚,则网络搜索将弹出正确的答案或指针.

Lastly, there's no substitute for writing some code and testing it. If you do something wrong, either Terraform and/or the Azure API will tell you, and if it's unclear, a web search will pop up an answer or a pointer in the right direction.

这篇关于通过Terraform创建Azure Windows VM的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆