question

LeoHelhe-1090 avatar image
0 Votes"
LeoHelhe-1090 asked LeoHelhe-1090 answered

Fail to apply artifact on VMs created from template

I created an environment using a template that defines a Microsoft.Compute/virtualMachines resource and a Microsoft.Compute/virtualMachines/extensions resource to run CustomScript to do some post-deploy stuff.

But when I tried to apply an artifact on the created VM in the portal, it failed with the following error.

 {"error":{"code":"BadRequest","message":"Multiple VMExtensions per handler not supported for OS type 'Linux'. VMExtension 'CustomScript' with handler 'Microsoft.Azure.Extensions.CustomScript' already added or specified in input."}}
    
 The 'FMS_Linux' artifact failed to install. See artifact result for details.


Can anyone help why the error occurred? Does it mean VMs that have defined "CustomScript" can never use the artifact features? Thanks in advance.


The extension resource definition is like below.

         {
             "name": "[concat(parameters('virtualMachineName'),'/PostDeploy')]",
             "type": "Microsoft.Compute/virtualMachines/extensions",
             "apiVersion": "2019-03-01",
             "location": "[variables('location')]",
             "dependsOn": [
                 "[resourceId('Microsoft.Compute/virtualMachines', parameters('virtualMachineName'))]"
             ],
             "properties": {
                 "publisher": "Microsoft.Azure.Extensions",
                 "type": "CustomScript",
                 "typeHandlerVersion": "2.1",
                 "autoUpgradeMinorVersion": true,
                 "settings": {
                     "skipDos2Unix": false,
                     "fileUris": [
                         "[variables('PostDeployScriptURL')]"
                     ],
                     "timestamp": 123456789,
                     "commandToExecute": "[concat('sh ',variables('PostDeployScript'), ' \"',parameters('DNS'),'\"' )]"
                 }
             }
         }



azure-virtual-machines
· 8
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@LeoHelhe-1090 , thank you for reaching out to us. I just wanted to confirm - are you using the same CustomScript extension for more than one scripts?

0 Votes 0 ·


Hi HarshitaSingh, thanks for the reply. Please reference the definition added.

The PostDeployScript variable is the filename of the script.
The PostDeployScriptURL is a constructed URL pointing to the script (same filename), but it looks like the URL is returning 404. I am still checking.

The template was committed also with a same filename script located under the same folder as azuredeploy.json.

Should I remove the fileUris?

0 Votes 0 ·

@LeoHelhe-1090, pls share your Shell script file as well for me to reproduce this issue. Consequently, try running the template in format as per Linux Extension schema. Additionally, pls make sure you run the script in Incremental mode.


0 Votes 0 ·

@LeoHelhe-1090 , just checking in to see if you got a chance to check my previous response.

0 Votes 0 ·
Show more comments

1 Answer

LeoHelhe-1090 avatar image
0 Votes"
LeoHelhe-1090 answered

Found that if I remove the extension resource from the template, I can apply artifacts for VMs created from this template.

I guess this is because the artifacts are applied via an extension created by Azure and the issue has the same cause as below.
https://stackoverflow.com/questions/42952273/multiple-vmextensions-per-handler-not-supported-for-os-type-linux

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.