Azure / Azure/azure-quickstart-templates

$StorageContainerName may contains space

Open
#8,725 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

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

### Issue Details
Deploy-AzTemplate.ps1 contains next code:
```
[string] $ResourceGroupName = (Split-Path $ArtifactStagingDirectory -Leaf),
[switch] $UploadArtifacts,
[string] $StorageAccountName,
[string] $StorageContainerName = $ResourceGroupName.ToLowerInvariant() + '-stageartifacts',
```
If $ArtifactStagingDirectory contains one or more spaces deploy script will try to create a container with spaces that are not allowed by Azure and results in the following error:
![image](https://user-images.githubusercontent.com/50662809/108877732-2fe0a700-7608-11eb-89ea-512c2b4e4ed0.png)

### Repro steps
1. .\Deploy-AZTemplate.ps1 -ArtifactStagingDirectory '.\Azure Policies\VM Onboarding\' -UploadArtifacts -TemplateFile '.\Azure Policies\VM Onboarding\azuredeploy.json' -TemplateParametersFile '.\Azure Policies\VM Onboarding\newdev.parameters.json'
### Fix propose:
Adding .Replace(" ","-") in line 11
` [string] $StorageContainerName = $ResourceGroupName.ToLowerInvariant().Replace(" ","-") + '-stageartifacts',`

Contributor guide

No contributing guide indexed for this repository

Research direction

Open Deploy-AzTemplate.ps1 and inspect the $StorageContainerName default near the parameter declarations. Reproduce the issue with the supplied -ArtifactStagingDirectory command using spaces, then verify that deployment succeeds and the resulting storage container name complies with Azure naming rules.

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
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.