How to load multiple template parameter files in BICEP

97 views Asked by At

I am trying to deploy multiple parameter files with loadjsoncontext for creation of NSG flow with Traffic Analytics in Azure with BICEP. Below is the template i have used currently to load two parameter files for a BICEP. One with pipeline parameter file to collect the value of Existing NSG and other parameter file I am using as a loadjsoncontext in BICEP instead of the Pipeline variable for the values of networkWatcherName, networkWatcherLocation, storageId, nsgResourceGroupName, workspaceId, workspaceRegion and workspaceResourceId

param nsgs array = []
param allowedVNetPrefixes array = []
param logRetentionDays int = 0
param subscriptionId string = subscription().subscriptionId

var nsgFlowLog = json(loadTextContent('./nsgFlowLogParameters/nsgFlowLogCLE_WESTEUROPE.json'))
var networkWatcherName = '${nsgFlowLog.networkWatcherName}'
var location = '${nsgFlowLog.location}'
var storageId = '${nsgFlowLog.storageId}'
var nsgResourceGroupName = '${nsgFlowLog.nsgResourceGroupName}'
var workspaceId = '${nsgFlowLog.workspaceId}'
var workspaceRegion = '${nsgFlowLog.workspaceRegion}'
var workspaceResourceId = '${nsgFlowLog.workspaceResourceId}'

resource flowLog 'Microsoft.Network/networkWatchers/flowLogs@2022-01-01' = [for nsg in nsgs: {
    name: '${networkWatcherName}/Microsoft.Network${nsgResourceGroupName}NSG_${replace(nsg.subnet, '/', '_')}'
    location: location
    properties: {
    targetResourceId: '/subscriptions/${subscriptionId}/resourceGroups/${nsgResourceGroupName}/providers/Microsoft.Network/networkSecurityGroups/NSG_${replace(nsg.subnet, '/', '_')}'
    storageId: storageId
    enabled: true
    format: {
      type: 'JSON'
      version: 2
    }
    retentionPolicy: {
      days: logRetentionDays
      enabled: true
    }
    flowAnalyticsConfiguration: {
      networkWatcherFlowAnalyticsConfiguration: {
        enabled: true
        workspaceId: workspaceId
        workspaceRegion: workspaceRegion
        workspaceResourceId: workspaceResourceId
      }
    }
}
}]

i am trying to test multiple parameter files with loadjsoncontext for each subscription. Each and every subscription i have a NSG resource group which contain the value of Nsgs and storage account. How to use all the parameter files for loadjsoncontext in BICEP?

0

There are 0 answers