-
-
Save justinyoo/5eb2bb5e5140396d20d1ab789c4048ae to your computer and use it in GitHub Desktop.
Passing Parameters to Linked ARM Templates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$projectName = "[TEMPLATE_PROJECT_NAME]" | |
$resourceGroupName = "[RESOURCE_GROUP_NAME]" | |
$storageAccountName = "[STORAGE_ACCOUNT_NAME]" | |
$containerName = "[CONTAINER_NAME]" | |
$segments = $resourceGroupName.Split("-") | |
$envName = $segments[$segments.Count - 1] | |
Set-AzureRmCurrentStorageAccount -ResourceGroupName $resourceGroupName -Name $storageAccountName | |
$templates = Get-ChildItem .\src\$projectName\Templates\*.params.json -Exclude ("base-*.json", "master-*.json") | |
foreach($template in $templates) | |
{ | |
$filePath = $template.FullName | |
$json = Get-Content -Path $filePath | ConvertFrom-Json | |
$json.parameters | Add-Member -MemberType NoteProperty -Name environment -Value @{ value = $envName } | |
$json | ConvertTo-Json -Depth 999 | Out-File -FilePath $filePath -Encoding utf8 | |
Set-AzureStorageBlobContent -Container $containerName -File $filePath -Force | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment