Azure / Azure/azure-quickstart-templates

Terraform : VMExtensionProvisioningError. Failed to download all specified files

Open
#7,525 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Bicep
Stars
14.9k
Forks
16.2k
Avg merge
6d 21h
Merged PRs (30d)
6

Description

I am trying to provision a vm and promote it to domain controller through a powershell script by running through customscriptextension of AzureRM, but it is giving an unexpected network close error. I am importing the powershell script from a github repository to be run post deployment Here is the code:

```
provider "azurerm" {
version = "~>1.44.0"
}

# Create a new resource group
resource "azurerm_resource_group" "rg" {
name = "myTFResourceGroup"
location = "eastus2"

tags = {
Environment = "Terraform Getting Started"
Team = "DevOps"
}
}
variable "prefix" {
default = "vmtrial"
}

resource "azurerm_virtual_network" "main" {
name = "${var.prefix}-network"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
}

resource "azurerm_subnet" "internal" {
name = "internal"
resource_group_name = azurerm_resource_group.rg.name
virtual_network_name = azurerm_virtual_network.main.name
address_prefix = "10.0.2.0/24"
}

resource "azurerm_public_ip" "main" {
name = "${var.prefix}-publicip"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
allocation_method = "Static"
}

resource "azurerm_network_security_group" "main" {
name = "${var.prefix}-nsg"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name

security_rule {
name = "test123"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "Tcp"
source_port_range = "*"
destination_port_range = "*"
source_address_prefix = "*"
destination_address_prefix = "*"
}

tags = {
environment = "Production"
}
}

resource "azurerm_network_interface" "main" {
name = "${var.prefix}-nic"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
network_security_group_id = azurerm_network_security_group.main.id

ip_configuration {
name = "testconfiguration1"
subnet_id = azurerm_subnet.internal.id
private_ip_address_allocation = "Dynamic"
public_ip_address_id = azurerm_public_ip.main.id
}
}

resource "azurerm_storage_account" "main" {
name = "*******************"
resource_group_name = azurerm_resource_group.rg.name
location = azurerm_resource_group.rg.location
account_tier = "Standard"
account_replication_type = "LRS"
}

resource "azurerm_storage_container" "main" {
name = "vhds"
resource_group_name = azurerm_resource_group.rg.name
storage_account_name = azurerm_storage_account.main.name
container_access_type = "private"
}

resource "azurerm_virtual_machine" "main" {
name = "${var.prefix}-vm"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
network_interface_ids = [azurerm_network_interface.main.id]
vm_size = "Standard_D2s_v3"

# Uncomment this line to delete the OS disk automatically when deleting the VM
delete_os_disk_on_termination = true

# Uncomment this line to delete the data disks automatically when deleting the VM
delete_data_disks_on_termination = true

storage_image_reference {
publisher = "MicrosoftWindowsServer"
offer = "WindowsServer"
sku = "2019-Datacenter"
version = "latest"
}
storage_os_disk {
name = "myosdisk1"
vhd_uri = "${azurerm_storage_account.main.primary_blob_endpoint}${azurerm_storage_container.main.name}/myosdisk1.vhd"
caching = "ReadWrite"
create_option = "FromImage"
#managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "hostname"
admin_username = "*********"
admin_password = "*************"
}

os_profile_windows_config{
provision_vm_agent = true
}

tags = {
Owner = "staging"
}
}

resource "azurerm_virtual_machine_extension" "test" {
name = "hostname"
location = azurerm_resource_group.rg.location
resource_group_name = azurerm_resource_group.rg.name
virtual_machine_name = azurerm_virtual_machine.main.name
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"

protected_settings = <

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reviewing the Terraform configuration, especially azurerm_virtual_machine_extension, its fileUris entry, and commandToExecute. Compare the reported VMExtensionProvisioningError with the linked Windows Custom Script Extension troubleshooting guidance. The issue does not specify a repository change or a concrete acceptance condition, so the required contribution remains undefined.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, github, powershell, terraform
Domain
cloud, devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.