I have an Azure ARM Teamplate that should create a Linux VM with Docker. Docker is installed using Azure's DockerExtension
. After Docker is installed, I need to run a custom script using Azure's CustomScriptForLinux
. Therefore, the second script should depend on the Docker installation. Here is an example that shows how I tried to write that in an ARM template:
{
...,
"variables": {
"extensionName": "DockerExtension",
"vmName": "Docker",
...
},
"resources": [
...,
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'), '/', variables('extensionName'))]",
"tags": {
"displayName": "DockerExtension"
},
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/', variables('vmName'))]"
],
"properties": {
"publisher": "Microsoft.Azure.Extensions",
"type": "DockerExtension",
"typeHandlerVersion": "1.1",
"autoUpgradeMinorVersion": true,
"settings": { }
}
},
{
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'), '/config')]",
"apiVersion": "2015-06-15",
"location": "[resourceGroup().location]",
"dependsOn": [
"[concat('Microsoft.Compute/virtualMachines/extensions/', variables('vmName'), '/', variables('extensionName'))]"
],
"properties": {
"publisher": "Microsoft.OSTCExtensions",
"type": "CustomScriptForLinux",
"typeHandlerVersion": "1.4",
"settings": {
"fileUris": [
"..."
],
"commandToExecute": "bash configure.sh"
}
}
}
]
}
If I run this ARM template, I get the error The resource
'Microsoft.Compute/virtualMachines/extensions/Docker/DockerExtension' is not defined in the template.
I don't understand why. This is the name of the Docker extension I have in my template, isn't it?
The template works if I run just one of the scripts. So there should not be a general error in the template.
Any help appreciated.
Regards, Rainer.
To modify existing resources using ARM templates, export the template for the resource from within the Azure Portal. Then download it locally. You can then modify it to update settings for Cosmos resources. ARM templates have api-versions.
In this post, we will review reference() function which often comes handy when working with ARM templates. This function allows to retrieving runtime state of a resource which contains useful information such as URIs, names or other settings.
You could try to use the ARM template function resourceId() in your ARM template to reference the Docker extension resource as shown below.
"type": "Microsoft.Compute/virtualMachines/extensions",
"name": "[concat(variables('vmName'), '/config')]",
"dependsOn": [
"[resourceId('Microsoft.Compute/virtualMachines/extensions', variables('vmName'), variables('extensionName'))]"
],...
Reference: Azure Resource Manager template functions
https://azure.microsoft.com/en-gb/documentation/articles/resource-group-template-functions/#resourceid
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With