Azure / Azure/azure-quickstart-templates

Deploy-AzTemplate unnecessarily requires the template file to be present in the artifact staging folder

Open
#13,110 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Bicep
Stars
14.9k
Forks
16.2k
Avg merge
6d 21h
Merged PRs (30d)
6

Description

[Deploy-AzTemplate.ps1](https://github.com/Azure/azure-quickstart-templates/blob/master/Deploy-AzTemplate.ps1)

### Deploy-AzTemplate incorrectly assumes that the template is always in the artifacts folder

If you try to use deploy-aztemplate to deploy a webapp from a local build using a sequence like this...
```
# Publish an app based on a standard template and some localised parameters....
cd my-web-app
dotnet publish .\my-web-app.csproj -c Release /p:PackageLocation=C:\staging\package.zip /p:TargetFramework=net6.0 /p:WebPublishMethod=Package

#Previous lines are for context only - the Deploy-AzTemplate step
#with specific -TemplateFile parameter is the relevant one
Deploy-AzTemplate.ps1 -TemplateFile \mytemplates\webapp.bicep -TemplateParametersFile .\my-web-app.parameters.json -ArtifactstagingDirectory c:\staging -ResourceGroupName myresource -location "West US"
```

then the process will fail because at lines 207 and 210 there is an assumption that the template file is present in the artifact staging folder.

I can't see any reason why it would be required (or even desirable) to deploy the resources using the _uploaded_ template file and in fact it works perfectly well in this scenario if the the code is modified to simply set TemplateUri to the value of $TemplateFile.

I would suggest either modifying lines 207 and 210 to read

$TemplateArgs.Add('TemplateUri', $TemplateFile)

or to add logic to either automatically copy the template file to staging folder if not present or to do the local path assignment if the template file is NOT in the staging folder.

I'd be happy to raise a PR but not sure which of these options is preferred.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in Deploy-AzTemplate.ps1 at lines 207 and 210, where the template path is handled, and compare the behavior when -TemplateFile points outside the artifact staging directory. Use the deployment command shown in the issue with the local Bicep template and parameters file. Done means the deployment no longer requires the template to be present in the staging folder.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, powershell
Domain
cloud, devops
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.