Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(azure): create azure monitor workspace #1485

Merged
merged 5 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 12 additions & 0 deletions .azure/infrastructure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,18 @@ module appInsights '../modules/applicationInsights/create.bicep' = {
}
}

module monitorWorkspace '../modules/monitor-workspace/main.bicep' = {
scope: resourceGroup
name: 'monitorWorkspace'
params: {
namePrefix: namePrefix
location: location
subnetId: vnet.outputs.monitorSubnetId
vnetId: vnet.outputs.virtualNetworkId
tags: tags
}
}

module apimAvailabilityTest '../modules/applicationInsights/availabilityTest.bicep' = {
scope: resourceGroup
name: 'apimAvailabilityTest'
Expand Down
75 changes: 75 additions & 0 deletions .azure/modules/monitor-workspace/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
@description('The prefix used for naming resources to ensure unique names')
param namePrefix string

@description('The location where the resources will be deployed')
param location string

@description('The ID of the subnet for the Private Link')
param subnetId string

@description('Tags to apply to resources')
param tags object

@description('The ID of the virtual network for the private DNS zone')
param vnetId string

resource monitorWorkspace 'Microsoft.Monitor/accounts@2023-04-03' = {
name: '${namePrefix}-monitor'
location: location
properties: {
publicNetworkAccess: 'Disabled'
}
tags: tags
}

// private endpoint name max characters is 80
var monitorPrivateEndpointName = '${namePrefix}-monitor-pe'

resource monitorPrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-03-01' = {
name: monitorPrivateEndpointName
location: location
properties: {
privateLinkServiceConnections: [
{
name: monitorPrivateEndpointName
properties: {
privateLinkServiceId: monitorWorkspace.id
groupIds: [
'prometheusMetrics'
]
}
}
]
customNetworkInterfaceName: '${namePrefix}-monitor-pe-nic'
subnet: {
id: subnetId
}
}
tags: tags
}

module privateDnsZone '../privateDnsZone/main.bicep' = {
name: '${namePrefix}-monitor-pdz'
params: {
namePrefix: namePrefix
defaultDomain: 'privatelink.${location}.prometheus.monitor.azure.com'
vnetId: vnetId
tags: tags
}
}

module privateDnsZoneGroup '../privateDnsZoneGroup/main.bicep' = {
name: '${namePrefix}-monitor-privateDnsZoneGroup'
dependsOn: [
privateDnsZone
]
params: {
name: 'default'
dnsZoneGroupName: 'privatelink-${location}-prometheus-monitor-azure-com'
dnsZoneId: privateDnsZone.outputs.id
privateEndpointName: monitorPrivateEndpoint.name
}
arealmaas marked this conversation as resolved.
Show resolved Hide resolved
}

output monitorWorkspaceId string = monitorWorkspace.id
output monitorWorkspaceName string = monitorWorkspace.name
54 changes: 54 additions & 0 deletions .azure/modules/vnet/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,44 @@ resource serviceBusNSG 'Microsoft.Network/networkSecurityGroups@2024-03-01' = {
tags: tags
}

resource monitorNSG 'Microsoft.Network/networkSecurityGroups@2024-03-01' = {
name: '${namePrefix}-monitor-nsg'
location: location
properties: {
securityRules: [
{
name: 'AllowAzureMonitorInbound'
type: 'Microsoft.Network/networkSecurityGroups/securityRules'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRanges: ['443']
sourceAddressPrefix: 'AzureMonitor'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 120
direction: 'Inbound'
}
}
{
name: 'AllowAzureMonitorOutbound'
type: 'Microsoft.Network/networkSecurityGroups/securityRules'
properties: {
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRanges: ['443']
sourceAddressPrefix: '*'
destinationAddressPrefix: 'AzureMonitor'
access: 'Allow'
priority: 120
direction: 'Outbound'
}
}
]
}
tags: tags
}

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2024-03-01' = {
name: '${namePrefix}-vnet'
location: location
Expand Down Expand Up @@ -334,6 +372,17 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2024-03-01' = {
}
}
}
{
name: 'monitorSubnet'
properties: {
addressPrefix: '10.0.6.0/24'
networkSecurityGroup: {
id: monitorNSG.id
}
privateEndpointNetworkPolicies: 'Disabled'
privateLinkServiceNetworkPolicies: 'Enabled'
}
}
]
}
tags: tags
Expand Down Expand Up @@ -362,3 +411,8 @@ output redisSubnetId string = resourceId(
virtualNetwork.name,
'redisSubnet'
)
output monitorSubnetId string = resourceId(
'Microsoft.Network/virtualNetworks/subnets',
virtualNetwork.name,
'monitorSubnet'
)
Loading