Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions infra/app/app-env.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ param location string
param logAnalyticsWorkspaceName string
param applicationInsightsName string
param daprEnabled bool
param vnetName string

// Container apps host (including container registry)
module containerApps '../core/host/container-apps.bicep' = {
Expand All @@ -16,6 +17,7 @@ module containerApps '../core/host/container-apps.bicep' = {
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
applicationInsightsName: applicationInsightsName
daprEnabled: daprEnabled
vnetName: vnetName
}
}

Expand Down
10 changes: 10 additions & 0 deletions infra/core/host/container-apps-environment.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ param logAnalyticsWorkspaceName string
param applicationInsightsName string = ''
param daprEnabled bool = false

@description('Name of the Vnet')
param vnetName string

resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01' = {
name: name
location: location
Expand All @@ -19,9 +22,16 @@ resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2022-03-01'
}
}
daprAIInstrumentationKey: daprEnabled && applicationInsightsName != '' ? applicationInsights.properties.InstrumentationKey : ''
vnetConfiguration: {
infrastructureSubnetId: vnet.properties.subnets[0].id
}
}
}

resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' existing = {
name: vnetName
}

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2022-10-01' existing = {
name: logAnalyticsWorkspaceName
}
Expand Down
2 changes: 2 additions & 0 deletions infra/core/host/container-apps.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ param containerRegistryName string = ''
param logAnalyticsWorkspaceName string = ''
param applicationInsightsName string = ''
param daprEnabled bool = false
param vnetName string

module containerAppsEnvironment 'container-apps-environment.bicep' = {
name: '${name}-container-apps-environment'
Expand All @@ -17,6 +18,7 @@ module containerAppsEnvironment 'container-apps-environment.bicep' = {
logAnalyticsWorkspaceName: logAnalyticsWorkspaceName
applicationInsightsName: applicationInsightsName
daprEnabled: daprEnabled
vnetName: vnetName
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}

Expand Down
30 changes: 30 additions & 0 deletions infra/core/networking/vnet.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
param location string
param vnetName string
param vnetPrefix string
param subnets array

resource vnet 'Microsoft.Network/virtualNetworks@2021-05-01' = {
name: vnetName
location: location
properties: {
addressSpace: {
addressPrefixes: [
vnetPrefix
]
}
subnets: subnets
}
}

@batchSize(1)
resource vnetSubnets 'Microsoft.Network/virtualNetworks/subnets@2020-08-01' = [ for subnet in subnets: {
parent: vnet
name: '${subnet.name}'
properties: {
addressPrefix: subnet.properties.addressPrefix
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}]

output vnetName string = vnet.name
25 changes: 25 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ param workerImageName string = ''
var abbrs = loadJsonContent('./abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var tags = { 'azd-env-name': environmentName }
param vnetName string = 'vnet-ca'
param vnetPrefix string = '10.0.0.0/16'

// Organize resources in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
Expand All @@ -58,6 +60,29 @@ module appEnv './app/app-env.bicep' = {
logAnalyticsWorkspaceName: monitoring.outputs.logAnalyticsWorkspaceName
applicationInsightsName: monitoring.outputs.applicationInsightsName
daprEnabled: true
vnetName: vnet.outputs.vnetName
}
}
var containerAppsSubnet = {
name: 'ContainerAppsSubnet'
properties: {
addressPrefix: '10.0.0.0/23'
}
}

var subnets = [
containerAppsSubnet
]

// Deploy an Azure Virtual Network
module vnet 'core/networking/vnet.bicep' = {
name: '${deployment().name}--vnet'
scope: rg
params: {
location: location
vnetName: vnetName
vnetPrefix: vnetPrefix
subnets: subnets
}
}

Expand Down