Automation of azure VM initial state via custom script extensions and Terraform
- Terraform: https://trello.com/c/lEv89VzJ
- IIS: https://trello.com/c/abEYNHOT
- Edge browser choco install microsoft-edge -y
- Visual studio community choco install visualstudio2022community -y
- Internet Information Services (IIS)
- Git choco install git.install
- .NET Framework 4.8 SDK choco install netfx-4.8-devpack
- .NET 6 choco install dotnet-6.0-sdk
- OpenSsl choco install openssl
- PowerShell Core choco install powershell-core
- WinRAR choco install winrar
- Notepad++ choco install notepadplusplus
- SQL Server 2019 Developer choco install sql-server-2019 -y
- SQL Server Management Studio choco install sql-server-management-studio
- NVM for Windows choco install nvm
- Create custom script extension
ps1
file - Create blob storage account and container
- Upload
ps1
file to blob storage - Create windows virtual machine
- Deploy custom script extension to virtual machine providing custom script extension
ps1
file url from step 3
- Print available azure vm images:
- Print available azure vm sizes:
az vm list-sizes -l "northeurope"
az vm list-skus -l "northeurope" --size Standard_B4ms
- https://docs.microsoft.com/en-us/cli/azure/vm?view=azure-cli-latest#az-vm-list-sizes
- Custom script extension docs: https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows
- https://azure.microsoft.com/es-es/blog/chocolatey-with-custom-script-extension-on-azure-vms/
- https://devkimchi.com/2020/08/26/app-provisioning-on-azure-vm-with-chocolatey-for-live-streaming/
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_group
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_interface_security_group_association
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/network_security_rule
- https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension
Name | Version |
---|---|
azurerm | =3.71.0 |
Name | Version |
---|---|
azurerm | 3.71.0 |
Name | Source | Version |
---|---|---|
custom_script_extension | ./modules/custom-script-extension | n/a |
key_vault | ./modules/keyvault | n/a |
key_vault_secrets | ./modules/keyvault-secrets | n/a |
keyvault_access_policy | ./modules/keyvault-access-policy | n/a |
network | ./modules/network | n/a |
storage | ./modules/storage | n/a |
virtual_machine | ./modules/vm | n/a |
Name | Type |
---|---|
azurerm_resource_group.public | resource |
azurerm_client_config.current | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
custom_script_extension_enabled | Specifies whether the extension should be enabled or disabled. | bool |
n/a | yes |
keyvault_enabled | Specifies whether the keyvault should be enabled or disabled. | bool |
n/a | yes |
os_profile_admin_password | Specifies the password of the administrator account. | string |
n/a | yes |
os_profile_admin_username | Specifies the name of the administrator account. | string |
n/a | yes |
prefix | Resources name prefix | string |
n/a | yes |
resource_group_location | Resource group location | string |
n/a | yes |
resource_group_name | Resource group name | string |
n/a | yes |
storage_account_replication | Specifies the replication type for this storage account. | string |
n/a | yes |
storage_account_tier | Specifies the tier to use for this storage account. | string |
n/a | yes |
storage_enabled | Specifies whether the storage should be enabled or disabled. | bool |
n/a | yes |
storage_image_reference_sku | Specifies the SKU of the platform image or marketplace image used to create the virtual machine. | string |
n/a | yes |
vm_size | The size of the virtual machine. | string |
n/a | yes |
Name | Description |
---|---|
public_ip | n/a |
username | n/a |