Skip to content

Instantly share code, notes, and snippets.

@justinyoo
Created August 5, 2016 09:42
Show Gist options
  • Save justinyoo/5eb2bb5e5140396d20d1ab789c4048ae to your computer and use it in GitHub Desktop.
Save justinyoo/5eb2bb5e5140396d20d1ab789c4048ae to your computer and use it in GitHub Desktop.
Passing Parameters to Linked ARM Templates
$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