Azure / template-specs

MIT License
31 stars 4 forks source link

Unable to create a version using ARM #55

Closed lukearp closed 3 years ago

lukearp commented 3 years ago

I am trying to create a Template Spec and Version via an ARM template. I can create the Template Spec object no problem, but I get an error on the version. The exact error I get is:

{
    "error": {
        "code": "InvalidTemplateDeployment",
        "message": "The template deployment 'test' is not valid according to the validation procedure. The tracking id is '4ba8dde5-8771-42e6-a201-19e0d2094afe'. See inner errors for details.",
        "details": [{
            "code": "DeploymentPreflightValidationFailed",
            "target": "/subscriptions/4bb3900a-62d5-41a8-a02c-1b811cf079c7/resourceGroups/template-spec/providers/Microsoft.Resources/templateSpecs/Resource-Group-Deploy/versions/v1",
            "message": "The resource name 'Resource-Group-Deploy/v1' is not valid. The name can only contain alphanumeric, underscore, parentheses, hyphen, period (except at end), and Unicode characters that match the regular expression ^[-\\w\\._\\(\\)]+(?<!\\.)$."
        }]
    }
}

In this example the name of my Template Spec was 'Resource-Group-Deploy' and the Version Name was 'v1'. I have attempted to get this to deploy multiple ways and get the same error. The last attempt I followed the same syntax as the official documentation:

{
    "type": "Microsoft.Resources/templateSpecs",
    "apiVersion": "2021-05-01",
    "name": "[parameters('name')]",
    "location": "[parameters('location')]",
    "properties": {
        "displayName": "[parameters('name')]"
    },
    "resources": [{
        "type": "versions",
        "apiVersion": "2021-05-01",
        "location": "[parameters('location')]",
        "name": "[parameters('version')]",
        "properties": {
            "mainTemplate": "[parameters('template')]"
        },
        "dependsOn": [
            "[resourceId('Microsoft.Resources/templateSpecs', parameters('name'))]"
        ]
    }]
}

This at onetime was working, since I have successfully created and updated Template Spec versions via CI/CD pipelines in the past. It seems like the API isn't parsing the Version name properly. Since 'versions' is a child resource of TemplateSpec, it would be referenced in the following syntax:

"type": "Microsoft.Resources/templateSpecs/versions" "name": "TemplateSpecName/VersionName"

The actual name of the version is VersionName, not "TemplateSpecName/VersionName". The error is picking up on the '/' as an invalid character for the version name, when it should just be passing the string after the '/'.

alex-frankel commented 3 years ago

We've identified the root cause of this and have a fix currently in PR. This is an internal link, but will keep it here for reference: https://msazure.visualstudio.com/One/_git/Mgmt-Governance-Blueprint/pullrequest/4629310

stuhay commented 3 years ago

We also have this issue, it's causing a holdup on all our releases.

Is there an ETA, or at least a workaround?

alex-frankel commented 3 years ago

The PR has been merged so it shouldn't be much longer than a week. @stuartko -- do you have a more precise ETA?

stuartko commented 3 years ago

The deployment is currently in progress, it's deployed to our lower traffic regions already, and should reach all regions by the end of the week (optimistically by Thursday).

alex-frankel commented 3 years ago

This fix has been deployed. Let us know if you are still seeing this.