0
votes

Usecase: I need to launch VM with VMSS inside application gateway depending on CPU utilization . In VMSS I need to execute once script if anyone has done this before please share the doc for same.

Thanks.

I have created a custom template but during deployment giving error: { "status": "Failed", "error": { "code": "ResourceDeploymentFailure", "message": "The resource operation completed with terminal provisioning state 'Failed'.", "details": [ { "code": "VMExtensionProvisioningError", "message": "VM has reported a failure when processing extension 'updatescriptextension'. Error message: \"Enable failed: failed to execute command: command terminated with exit status=1\"." }

Template: https://github.com/linuxgambler/azure/blob/master/vmss.json

2

2 Answers

1
votes

You could create a single Azure Resource Manager template that creates an App Gateway, scale set, and autoscale rules. I'm not aware of a single example, but there are examples of App Gateway VMSS templates here: https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-ubuntu-app-gateway and here: https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-windows-app-gateway An example using autoscale rules for CPU usage is here: https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-ubuntu-autoscale and here: https://github.com/Azure/azure-quickstart-templates/tree/master/201-vmss-windows-autoscale - you could take the autoscale rules from the latter examples and add them to an app gateway template.

If you create such a template you can script its deployment with PowerShell or CLI. If you are looking to imperatively create resources and add autoscale rules using PowerShell or CLI commands, you can do this too, though again I'm not aware of a one-stop example script, but you can build a script from other examples. For example, instructions for adding autoscale rules to a scale set using PowerShell can be found here: https://msftstack.wordpress.com/2017/03/05/how-to-add-autoscale-to-an-azure-vm-scale-set/

0
votes

That error message you're seeing is due to the custom script extension for linux you are running; in your configuration you have:

"settings": { "commandToExecute": "sh /test.sh", "enableInternalDNSCheck": "false" }

But there's no fileUris key to specify where the test.sh file is to be downloaded from (example of how to do this here: https://github.com/Azure/azure-quickstart-templates/blob/master/201-vmss-bottle-autoscale/azuredeploy.json#L229). So it could be that the test.sh file isn't on the VM (unless you got it there some other way?); it could also be something else; you could check the logs in /var/lib/waagent to see what how far the extension got; if you see files in /var/lib/waagent/custom-script/downloads/0, then you should be able to see the stdout and stderr logged there as well.