How to configure windows ado agent using powershell script in a terraform module

OYETI, ISHAU 5 Reputation points
2024-09-06T22:35:41.0433333+00:00

I am using terraform to provision a vm and using a powershell script to install and configure ado agent on the vm upon creation. I have the powershell script both in azure blob storage and in my github repo. However the vm is still unable to route to both the github repo and blob storage to download the script. I keep getting the following error:

Error: Code="VMExtensionProvisioningError" Message="VM has reported a failure when processing extension 'ConfigureADOAgent' (publisher 'Microsoft.Compute' and type 'CustomScriptExtension'). Error message: 'File download failure'. More information on troubleshooting is available at https://aka.ms/VMExtensionCSEWindowsTroubleshoot. "

│ with azurerm_virtual_machine_extension.extension[0],

│ on resource.tf line 87, in resource "azurerm_virtual_machine_extension" "extension":

│ 87: resource "azurerm_virtual_machine_extension" "extension" {

Here is a snippet of the block of code in the terraform config that creates the custom script extension;

resource "azurerm_virtual_machine_extension" "extension" {

count = var.no_of_vm

name = "ConfigureADOAgent"

virtual_machine_id = azurerm_windows_virtual_machine.ado_agent[count.index].id

publisher = "Microsoft.Compute"

type = "CustomScriptExtension"

type_handler_version = "1.10"

settings = <<SETTINGS

{

    "fileUris": ["https://winadoblob.blob.core.windows.net/newcontainer/userdata.ps1"],

    "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File userdata.ps1"

}

SETTINGS

}

Windows Server 2019
Windows Server 2019
A Microsoft server operating system that supports enterprise-level management updated to data storage.
3,785 questions
Windows Server 2012
Windows Server 2012
A Microsoft server operating system that supports enterprise-level management, data storage, applications, and communications.
1,598 questions
Windows 365 Business
Windows 10 Compatibility
Windows 10 Compatibility
Windows 10: A Microsoft operating system that runs on personal computers and tablets.Compatibility: The extent to which hardware or software adheres to an accepted standard.
480 questions
Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
9,847 questions
0 comments No comments
{count} vote

1 answer

Sort by: Most helpful
  1. Shipra Shah 6 Reputation points
    2024-10-29T18:06:00.3933333+00:00

    I have the same situation. can someone please advise?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.