Azure / Azure/azure-quickstart-templates
Deploy-AzureResourceGroup.ps1 fails to upload artifacts with new cmdlets
- Dominant language
- Bicep
- Stars
- 14.9k
- Forks
- 16.2k
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 6
Description
Script: Deploy-AzureResourceGroup.ps1
### Issue Details
New version 3.0.0 of AzureRm have changed output of ```Get-AzureRmContext``` now it returns subscription id as ```(Get-AzureRmContext).Subscription.Id``` instead of ```(Get-AzureRmContext).Subscription.SubscriptionId``` in earlier versions.
this produces error when using -UploadArtifacts switch
I believe code need to be changed so it can handle both newer and older versions of cmdlets, for example, change from:
```
# Create a storage account name if none was provided
if($StorageAccountName -eq "") {
$subscriptionId = ((Get-AzureRmContext).Subscription.SubscriptionId).Replace('-', '').substring(0, 19)
$StorageAccountName = "stage$subscriptionId"
}
```
to something like
```
# Create a storage account name if none was provided
if($StorageAccountName -eq "") {
if ((get-command get-azurermcontext).version -ge "3.0")
{
$subscriptionId = ((Get-AzureRmContext).Subscription.Id).Replace('-', '').substring(0, 19)
}
else
{
$subscriptionId = ((Get-AzureRmContext).Subscription.SubscriptionId).Replace('-', '').substring(0, 19)
}
$StorageAccountName = "stage$subscriptionId"
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in Deploy-AzureResourceGroup.ps1 and inspect the storage-account naming path used with the -UploadArtifacts switch. Check how Get-AzureRmContext exposes the subscription identifier in the older and newer cmdlet versions. Done means artifact upload works and the generated storage account name is correct with both versions.
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