I auto answer this question.
I have redone the whole process, and starting the vm with the template works fine.
I wanted to set a specific image name. I added a parameter imageName
Now I updated the template.json by adding a parameter
"parameters": {
"location": {
"type": "string"
},
"imageName": {
"type": "string"
},
"networkInterfaceName": {
Updated where it is used
"storageProfile": {
"osDisk": {
"createOption": "fromImage",
"managedDisk": {
"storageAccountType": "[parameters('osDiskType')]"
}
},
"imageReference": {
"id": "/subscriptions/14b6e880-753e-4a5f-8618-c0786702aa1c/resourceGroups/MsOps-Horizon-rg/providers/Microsoft.Compute/images/[parameters('imageName')]"
}
},
But when doing the creation process fails with the same reason
Deployment failed. Correlation ID: 39b18e50-ff0d-4ecd-a3e8-e40b988a341b. {
"error": {
"code": "InvalidParameter",
"message": "The entity name 'vmImageName' is invalid according to its validation rule: ^[^\W][\w-.]{0,79}(?<![-.])$.",
"target": "vmImageName"
}
}
Creation of vm failed
My workaround is therefore to do a sed in the template.json to insert the image name I want :(
My guess is that the [parameter('imageName')] is not expanded early enough which makes the process fails as the name does not match the matching rule