Azure / template-specs

MIT License
31 stars 4 forks source link

Description property lost on version creation when using PowerShell - New-AzTemplateSpec #43

Closed stweb1963 closed 3 years ago

stweb1963 commented 3 years ago

The description is not retained when using PowerShell to create a templateSpec version There is no issue if performed using the portal

Sample Command


New-AzTemplateSpec -Version test -ResourceGroupName rgName dummy -Description 'test' -DisplayName 'test' -Location 'Canada Central' -TemplateFile .\azuredeploy.json -Force

Reference

image

stuartko commented 3 years ago

New-AzTemplateSpec has separate parameters for the root template spec description and the version description. To set the version description you can use the parameter -VersionDescription "your version description here"

If I have misunderstood the issue you're having here, please let me know, otherwise I will close this issue.

stweb1963 commented 3 years ago

Yes, looks like this was my issue, thanks Testing now, and will confirm

A little misleading as I assumed if using -Version parameter then -Description would apply to the version

stuartko commented 3 years ago

When a version is being created, a "root" template spec resource (essentially a container) is updated/created too, so we need to provide the capability of providing a description for both the root and the version independently, which unfortunately can cause some confusion.

If you have suggestions on how this may be improved, we're very open to improvements/changes.

For now I'll close this issue.

stweb1963 commented 3 years ago

So testing proved successful but this is how I need to handle it base on how tagging get applied

To separate templateSpec 'root' tags from 'version' tags you need to use Set-AzTemplateSpec first (no version) Then push the version with the tags specific to the version => New-AzTemplateSpec -Version

If you push the version without first creating the root, the specific version tags are attached to the root so I need to so something like this

#first (only once if the spec does not exist)
Set-AzTemplateSpec -Name name -ResourceGroupName rgName -Location canadacentral `
  -Description 'description' -Tag @{'rootTag'='a tag value'}

#then we  do this ongoinging
New-AzTemplateSpec -Name name -ResourceGroupName rgName -Location canadacentral `
  -Version '1.0.0' -VersionDescription 'description' `
  -Tag @{'versionTag'='a tag value'} -TemplateFile ./main.json 
alex-frankel commented 3 years ago

I think the only alternative is to not tag the root template spec when you are creating parent + version. Would that work better for you? We could also introduce a flag to control the behavior like -OnlyTagVersion or something like that