azure-docs icon indicating copy to clipboard operation
azure-docs copied to clipboard

Issue with deploying custom software extension

Open BillysCoolJob opened this issue 3 years ago • 3 comments

When using Terraform to setup software extensions for resources using the following code:

`resource "azurerm_virtual_machine_extension" "dc_software" { count = local.dc_count name = "DC-SetupScript-${format("%02d", count.index + 1)}" virtual_machine_id = azurerm_windows_virtual_machine.DC[count.index].id publisher = "Microsoft.Compute" type = "CustomScriptExtension" type_handler_version = "1.10"

protected_settings = <<SETTINGS { "commandToExecute": "powershell -command "[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(data.template_file.tf_setup.rendered)}')) | Out-File -filepath setup.ps1" && powershell -ExecutionPolicy Unrestricted -File setup.ps1" } SETTINGS }`

I get the following error:

Error: compute.VirtualMachineExtensionsClient#CreateOrUpdate: Failure sending request: StatusCode=404 -- Original Error: Code="ExtensionNotFoundForCPUArchitecture" Message="Extension with publisher 'Microsoft.Compute', type 'CustomScriptExtension', and type handler version '1.10' for CPU Architecture 'x64' was not found in the extension repository."

It appears to run the script in question, but errors out afterwards causing a halt in the deployment. Issue was not happening last Friday (August 12, 2022)

Azure CLI 2.39.0 Powershell: 7.2.6 Terraform Provider AzureRM 3.18.0


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

BillysCoolJob avatar Aug 15 '22 20:08 BillysCoolJob

@BillysCoolJob It would be great if you could add a link to the documentation you are following for these steps? This would help us redirect the issue to the appropriate team. Thanks!!

If the issue is not related any particular documentation, you could also post the issue on MS Q&A with the appropriate service tag so other users and experts could chip in.

RohitMungi-MSFT avatar Aug 16 '22 04:08 RohitMungi-MSFT

Hi @RohitMungi-MSFT ! Yes here are some links to what I am following: Terraform documentation for Azure resource: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/virtual_machine_extension

Microsoft Documentation for the CustomScriptExtension: https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows

Then I used the following commands to get the supported software extensions: az vm extension image list --location westus -o table

Grabbed the following details from that output: Publisher: "Microsoft.Compute" Type: "CustomScriptExtension" Latest version: "1.10.12" As far as I am aware inputting "1.10" will auto upgrade the patch version to use "1.10.12"

If I am reading the error correctly, the Terraform resource is getting a 404 when trying to find the software extension "Microsoft.Compute.CustomScriptExtension"

BillysCoolJob avatar Aug 16 '22 14:08 BillysCoolJob

Thanks for the links & details. I have assigned the issue to the appropriate area to check further. Thanks!!

RohitMungi-MSFT avatar Aug 16 '22 14:08 RohitMungi-MSFT

Hi @Karishma-Tiwari-MSFT ! Not to pester, but unfortunately this issue is starting to become urgent for us. Is there any chance you could take a look? I see that this has happened before with other extensions here: https://bytemeta.vip/repo/MicrosoftDocs/azure-docs/issues/92474

Looks like it needed to be resolved from the Azure side.

BillysCoolJob avatar Aug 18 '22 14:08 BillysCoolJob

@BillysCoolJob I would suggest that opening a support ticket through the Azure Portal on a resource experiencing this issue would be the best path forward for you to get this resolved as this will require looking at logs to properly troubleshoot this issue.

MsGabsta avatar Aug 18 '22 14:08 MsGabsta

@BillysCoolJob is this a new deployment with Custom Script Extension being installed for the first time on the resource?

MsGabsta avatar Aug 18 '22 15:08 MsGabsta

@MsGabsta Yes, it is a new deployment. The deployment is designed to be built up and torn down as needed (spin up for a couple days, use it, then tear it down) and it gives us the error every time I've run it since Monday. As of this moment we don't have the plan in Azure to get technical support, so I'd have to go purchase that to proceed over there.

BillysCoolJob avatar Aug 18 '22 15:08 BillysCoolJob

@BillysCoolJob, thanks for the quick response. I'm discussing this internally and will respond again soon.

MsGabsta avatar Aug 18 '22 17:08 MsGabsta

@MsGabsta I've been testing this out a bit more, if I use Terraform, is my local machine reaching out to get Microsoft.Compute.CustomScriptExtension or is the VM itself reaching out to get it? Or, to ask another way, is my local machine getting the 404 or is the VM getting the 404? The script changes the DNS server in the subnet mid-deploy so I feel a DNS issue may be afoot.

BillysCoolJob avatar Aug 18 '22 17:08 BillysCoolJob

@BillysCoolJob It looks like by design - Only a single VM extension of a given type and version can be installed on a VM at one time, and trying to install a second one will result in an error. Specifying a custom script twice in the same Azure Resource Manager template for the same VM will fail.

Reference: Custom Script Extension Schema

If it is needed to execute more than one script, it is possible to add as many scripts as needed in the "fileuris" properties and then, use one of the scripts to call the other ones or add all of them in commandToExecute using && in between. Ex. "./script1.sh && ./script2.sh"

Please check if you have any conflicting existing extension installed, take a backup of the script used in that extension in case you need it in future and then uninstall that extension from Azure Portal. After uninstalling the conflicting extension, try installing the desired extension using Terraform. Let me know the results.

If this is not the case with you, please send an email to '[email protected]' with the Subject - Attn: Karishma Include your Subscription Id and a link to this thread in the email. I will enable a support request for you to get the necessary support.

@MsGabsta Thanks for sharing your insights.

Karishma-Tiwari-MSFT avatar Aug 18 '22 19:08 Karishma-Tiwari-MSFT

Hi @Karishma-Tiwari-MSFT This is not the case with me, however I did discover that this was in fact related to the DNS switch I was making and therefor we can close this case. My issue is no longer happening. Thank you for your help!

BillysCoolJob avatar Aug 18 '22 20:08 BillysCoolJob