New-AzBlueprintArtifact creates invalid artifacts
Description
When using New-AzBlueprintArtifact, if you chose to create an artifact from a template and a parameter file, a malformed artifact object is created. This happens when there are parameters specified in template parameters file with a type of array.
While the artifact is created successfully, if you then proceed to publish the blueprint you will get the following error:
Publish-AzBlueprint : This artifact is invalid. Error: 'The language expression '
"value1",
"value2"
' is not valid: the string character '"' at position '4' is not expected.'
At C:\src\temp\buildBlueprint.ps1:110 char:1
+ Publish-AzBlueprint -Blueprint $blueprint -Version "test"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Publish-AzBlueprint], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Blueprint.Cmdlets.PublishAzureRmBlueprint
Looking at the artifact using the REST API, I can see that parameter section of the artifact is actually malformed:
"parameters": {
"groupName": {
"value": "Informational alert receivers"
},
"shortName": {
"value": "InfoAlertGrp"
},
"emailAddresses": {
"value": "[\r\n \"value1\",\r\n \"value2\"\r\n]"
}
}
A correctly formed artifact parameter section looks like this in the rest api response
"parameters": {
"groupName": {
"value": "Informational alert receivers"
},
"shortName": {
"value": "InfoAlertGrp"
},
"emailAddresses": {
"value": [
"value1",
"value2"
]
}
}
It seems like this might be caused by the GetTemplateParametersFromFile function in the following class https://github.com/Azure/azure-powershell/blob/master/src/Blueprint/Blueprint/Cmdlets/BlueprintArtifacts/BlueprintArtifactsCmdletBase.cs :)
Steps to reproduce
# have a simple arm teplate with its parameter file for testing purposes, at least one parameter needs to be type of array and values hould supplied like ["value1","value2"]
New-AzBlueprintArtifact -Blueprint $blueprint -Name $templateDir.Name -Type TemplateArtifact -TemplateParameterFile $templateParameterFile -TemplateFile $templateFile -ResourceGroupName "bp-default-rg"
Publish-AzBlueprint -Blueprint $blueprint -Version "test"
Environment data
Name Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Module versions
ModuleType Version Name
---------- ------- ----
Script 0.2.0 Az.Blueprint
Debug output
Error output
@filizt Hey Filiz, would you mind taking a look at this issue?
@cormacpayne @kutluomeroglu Investigating.
@kutluomeroglu thanks for pointing out this bug. We have the fix, it should go out sometime next week.
@filizt is this fix out? We should close this if it's done