Skip to content

Commit

Permalink
Fix tag handling for methods which internally deploy using ARM templates
Browse files Browse the repository at this point in the history
  • Loading branch information
plzm committed Jan 10, 2024
1 parent 6312533 commit 86acc6f
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 22 deletions.
20 changes: 15 additions & 5 deletions scripts/AzureAppService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ function Deploy-AppInsights()

Write-Debug -Debug:$true -Message "Deploy App Insights $AppInsightsName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$AppInsightsName" `
Expand All @@ -49,7 +51,7 @@ function Deploy-AppInsights()
linkedStorageAccountResourceId="$LinkedStorageAccountResourceId" `
publicNetworkAccessForIngestion="$PublicNetworkAccessForIngestion" `
publicNetworkAccessForQuery="$PublicNetworkAccessForQuery" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -91,6 +93,8 @@ function Deploy-AppServiceCertificate()

Write-Debug -Debug:$true -Message "Deploy App Service Certificate $AppServiceCertificateName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$AppServiceCertificateName" `
Expand All @@ -102,7 +106,7 @@ function Deploy-AppServiceCertificate()
certificateName="$AppServiceCertificateName" `
keyVaultResourceId="$KeyVaultResourceId" `
keyVaultSecretName="$KeyVaultSecretName" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -195,6 +199,8 @@ function Deploy-AppService()

Write-Debug -Debug:$true -Message "Deploy App Service $AppServiceName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$AppServiceName" `
Expand Down Expand Up @@ -223,7 +229,7 @@ function Deploy-AppService()
allowedIpAddressRanges="$AllowedIpAddressRanges" `
customFqdn="$CustomFqdn" `
certificateForAppServiceThumbprint="$CertificateForAppServiceThumbprint" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -274,6 +280,8 @@ function Deploy-AppServicePlan()

Write-Debug -Debug:$true -Message "Deploy App Service Plan $AppServicePlanName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$AppServicePlanName" `
Expand All @@ -288,7 +296,7 @@ function Deploy-AppServicePlan()
capacity="$Capacity" `
kind="$Kind" `
zoneRedundant="$ZoneRedundant" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -333,6 +341,8 @@ function Deploy-AppServicePlanAutoscaleSettings()

Write-Debug -Debug:$true -Message "Deploy App Service Plan Autoscale Settings $AutoscaleSettingsName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$AutoscaleSettingsName" `
Expand All @@ -345,7 +355,7 @@ function Deploy-AppServicePlanAutoscaleSettings()
minimumInstances="$MinimumInstances" `
maximumInstances="$MaximumInstances" `
defaultInstances="$DefaultInstances" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down
4 changes: 3 additions & 1 deletion scripts/AzureKeyVault.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ function Deploy-KeyVault()

Write-Debug -Debug:$true -Message "Deploy Key Vault $KeyVaultName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$KeyVaultName" `
Expand All @@ -77,7 +79,7 @@ function Deploy-KeyVault()
defaultAction="$DefaultAction" `
allowedIpAddressRanges="$AllowedIpAddressRangesCsv" `
allowedSubnetResourceIds="$AllowedSubnetResourceIdsCsv" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down
20 changes: 15 additions & 5 deletions scripts/AzureMonitor.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function Deploy-ActionGroup()

Write-Debug -Debug:$true -Message "Deploy Action Group $ActionGroupName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$ActionGroupName" `
Expand All @@ -45,7 +47,7 @@ function Deploy-ActionGroup()
emailReceivers="$EmailReceivers" `
smsReceivers="$SmsReceivers" `
azureAppPushReceivers="$AzureAppPushReceivers" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -133,6 +135,8 @@ function Deploy-LogAnalyticsWorkspace()

Write-Debug -Debug:$true -Message "Deploy Log Analytics Workspace $WorkspaceName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$WorkspaceName" `
Expand All @@ -143,7 +147,7 @@ function Deploy-LogAnalyticsWorkspace()
workspaceName="$WorkspaceName" `
publicNetworkAccessForIngestion="$PublicNetworkAccessForIngestion" `
publicNetworkAccessForQuery="$PublicNetworkAccessForQuery" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -269,6 +273,8 @@ function Deploy-MonitorDataCollectionEndpoint()

Write-Debug -Debug:$true -Message "Deploy Data Collection Endpoint $DataCollectionEndpointName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$DataCollectionEndpointName" `
Expand All @@ -279,7 +285,7 @@ function Deploy-MonitorDataCollectionEndpoint()
name="$DataCollectionEndpointName" `
kind="$DataCollectionEndpointKind" `
publicNetworkAccess="$PublicNetworkAccess" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -318,6 +324,8 @@ function Deploy-MonitorDataCollectionRule()

Write-Debug -Debug:$true -Message "Deploy Data Collection Endpoint $DataCollectionRuleName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$DataCollectionRuleName" `
Expand All @@ -328,7 +336,7 @@ function Deploy-MonitorDataCollectionRule()
dataCollectionRuleName="$DataCollectionRuleName" `
logAnalyticsWorkspaceName="$LogAnalyticsWorkspaceName" `
logAnalyticsWorkspaceResourceId="$LogAnalyticsWorkspaceResourceId" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -445,6 +453,8 @@ function Deploy-MonitorPrivateLinkScope()

Write-Debug -Debug:$true -Message "Deploy Azure Monitor Private Link Scope $PrivateLinkScopeName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$PrivateLinkScopeName" `
Expand All @@ -455,7 +465,7 @@ function Deploy-MonitorPrivateLinkScope()
linkScopeName=$PrivateLinkScopeName `
queryAccessMode=$QueryAccessMode `
ingestionAccessMode=$IngestionAccessMode `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down
28 changes: 21 additions & 7 deletions scripts/AzureNetwork.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function Deploy-NetworkNic()

Write-Debug -Debug:$true -Message "Deploy NIC $NicName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$NicName" `
Expand All @@ -61,7 +63,7 @@ function Deploy-NetworkNic()
privateIpAddressVersion="$PrivateIpAddressVersion" `
publicIpResourceId="$PublicIpResourceId" `
ipConfigName="$IpConfigName" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -93,6 +95,8 @@ function Deploy-NetworkSecurityGroup() {

Write-Debug -Debug:$true -Message "Deploy NSG $NSGName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$NSGName" `
Expand All @@ -101,7 +105,7 @@ function Deploy-NetworkSecurityGroup() {
--parameters `
location="$Location" `
nsgName="$NSGName" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -230,6 +234,8 @@ function Deploy-NetworkPublicIp()
)
Write-Debug -Debug:$true -Message "Deploy PIP $PublicIpAddressName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$PublicIpAddressName" `
Expand All @@ -241,7 +247,7 @@ function Deploy-NetworkPublicIp()
publicIpType="$PublicIpAddressType" `
publicIpSku="$PublicIpAddressSku" `
domainNameLabel="$HostName" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -271,14 +277,16 @@ function Deploy-NetworkPrivateDnsZone()

Write-Debug -Debug:$true -Message "Deploy Private DNS Zone $DnsZoneName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$DnsZoneName" `
-g "$ResourceGroupName" `
--template-uri "$TemplateUri" `
--parameters `
privateDnsZoneName="$DnsZoneName" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -373,6 +381,8 @@ function Deploy-NetworkPrivateDnsZoneVNetLink()

Write-Debug -Debug:$true -Message "Deploy Private DNS Zone VNet Link $DnsZoneName to $VNetResourceId"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$DnsZoneName" `
Expand All @@ -382,7 +392,7 @@ function Deploy-NetworkPrivateDnsZoneVNetLink()
privateDnsZoneName="$DnsZoneName" `
vnetResourceId="$VNetResourceId" `
enableAutoRegistration=$false `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down Expand Up @@ -427,6 +437,8 @@ function Deploy-NetworkPrivateEndpointAndNic()

Write-Debug -Debug:$true -Message "Deploy Private Endpoint and NIC $PrivateEndpointName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$PrivateEndpointName" `
Expand All @@ -439,7 +451,7 @@ function Deploy-NetworkPrivateEndpointAndNic()
privateEndpointName="$PrivateEndpointName" `
networkInterfaceName="$NetworkInterfaceName" `
subnetResourceId="$SubnetResourceId" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

Write-Debug -Debug:$true -Message "Wait for NIC provisioning to complete"
Expand Down Expand Up @@ -589,6 +601,8 @@ function Deploy-NetworkVNet() {

Write-Debug -Debug:$true -Message "Deploy VNet $VNetName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$VNetName" `
Expand All @@ -600,7 +614,7 @@ function Deploy-NetworkVNet() {
vnetPrefix="$VNetPrefix" `
enableDdosProtection="$EnableDdosProtection" `
enableVmProtection="$EnableVmProtection" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down
4 changes: 3 additions & 1 deletion scripts/AzureSecurity.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ function Deploy-UserAssignedIdentity()

Write-Debug -Debug:$true -Message "Deploy UAI $UAIName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$UAIName" `
Expand All @@ -106,7 +108,7 @@ function Deploy-UserAssignedIdentity()
location="$Location" `
tenantId="$TenantId" `
identityName="$UAIName" `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down
4 changes: 3 additions & 1 deletion scripts/AzureStorage.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ function Deploy-StorageAccount()

Write-Debug -Debug:$true -Message "Deploy Storage Account $StorageAccountName"

$tagsForTemplate = Get-TagsForArmTemplate -Tags $Tags

$output = az deployment group create --verbose `
--subscription "$SubscriptionId" `
-n "$StorageAccountName" `
Expand All @@ -61,7 +63,7 @@ function Deploy-StorageAccount()
allowedSubnetResourceIds="$AllowedSubnetResourceIdsCsv" `
allowedIpAddressRanges="$AllowedIpAddressRangesCsv" `
defaultAccessAction=$DefaultAction `
tags=$Tags `
tags=$tagsForTemplate `
| ConvertFrom-Json

return $output
Expand Down
2 changes: 1 addition & 1 deletion scripts/AzureStorageCopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ function Copy-StorageTables()
$dfLsNameSink = $StorageAccountNameSink

Write-Debug -Debug:$true -Message "Create ADF RG $ResourceGroupNameDataFactory"
$tags = Get-Tags -EnvironmentName $EnvironmentName
$tags = Get-TagsForAzureCli -Tags "EnvironmentName=$EnvironmentName"
az group create -n $ResourceGroupNameDataFactory -l $Location --tags $tags

Write-Debug -Debug:$true -Message "Create ADF $DataFactoryName"
Expand Down
Loading

0 comments on commit 86acc6f

Please sign in to comment.