Skip to content
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
38 changes: 24 additions & 14 deletions Bicep/getavailability.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,20 @@ param dnsZonesSubscriptionId string = ''
@description('Resource group name containing existing Private DNS Zones. Required only when usePrivateEndpoints is true.')
param dnsZonesResourceGroupName string = ''

@description('Comma-separated list of Azure subscription names or IDs to monitor (written to GETAVAIL_SUBSCRIPTIONS app setting).')
@description('Comma-separated list of Azure subscription display names to monitor (written to GETAVAIL_SUBSCRIPTIONS app setting).')
param getavailSubscriptions string

@description('Comma-separated resource kinds to monitor. Default: vm,sql,storage,webapp')
param getavailKinds string = 'vm,sql,storage,webapp'

@description('Use the regional Metrics Batch API for the scheduled availability run.')
param getavailBatch bool = true

@description('Maximum resources per Metrics Batch API request.')
@minValue(1)
@maxValue(50)
param getavailBatchSize int = 10

@description('Log Analytics workspace customer ID used as source for Activity Log and Resource Health queries (SOURCE_WORKSPACE_ID app setting). Leave empty to skip.')
param sourceWorkspaceId string = ''

Expand All @@ -87,19 +95,19 @@ var functionAppPublicNetworkAccess = usePrivateEndpoints ? 'Disabled' : 'Enabled

// ── Existing Private DNS Zones ───────────────────────────────────────────────

resource blobDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' existing = if (usePrivateEndpoints) {
resource blobDnsZone 'Microsoft.Network/privateDnsZones@2024-06-01' existing = if (usePrivateEndpoints) {
name: 'privatelink.blob.${environment().suffixes.storage}'
scope: resourceGroup(dnsZonesSubscriptionId, dnsZonesResourceGroupName)
}

resource webAppDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' existing = if (usePrivateEndpoints) {
resource webAppDnsZone 'Microsoft.Network/privateDnsZones@2024-06-01' existing = if (usePrivateEndpoints) {
name: 'privatelink.azurewebsites.net'
scope: resourceGroup(dnsZonesSubscriptionId, dnsZonesResourceGroupName)
}

// ── Log Analytics Workspace ──────────────────────────────────────────────────

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2026-03-01' = {
name: logAnalyticsWorkspaceName
location: location
properties: {
Expand All @@ -113,7 +121,7 @@ resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09

// ── Custom Table: GetAvailResources_CL (per-resource detail) ─────────────────

resource resourcesTable 'Microsoft.OperationalInsights/workspaces/tables@2022-10-01' = {
resource resourcesTable 'Microsoft.OperationalInsights/workspaces/tables@2026-03-01' = {
name: 'GetAvailResources_CL'
parent: logAnalyticsWorkspace
properties: {
Expand Down Expand Up @@ -147,7 +155,7 @@ resource resourcesTable 'Microsoft.OperationalInsights/workspaces/tables@2022-10

// ── Custom Table: GetAvailSummary_CL (aggregated summaries) ──────────────────

resource summaryTable 'Microsoft.OperationalInsights/workspaces/tables@2022-10-01' = {
resource summaryTable 'Microsoft.OperationalInsights/workspaces/tables@2026-03-01' = {
name: 'GetAvailSummary_CL'
parent: logAnalyticsWorkspace
properties: {
Expand Down Expand Up @@ -176,7 +184,7 @@ resource summaryTable 'Microsoft.OperationalInsights/workspaces/tables@2022-10-0

// ── Data Collection Endpoint ─────────────────────────────────────────────────

resource dataCollectionEndpoint 'Microsoft.Insights/dataCollectionEndpoints@2023-03-11' = {
resource dataCollectionEndpoint 'Microsoft.Insights/dataCollectionEndpoints@2024-03-11' = {
name: dataCollectionEndpointName
location: location
properties: {
Expand All @@ -189,7 +197,7 @@ resource dataCollectionEndpoint 'Microsoft.Insights/dataCollectionEndpoints@2023

// ── Data Collection Rule (two streams, one per table) ────────────────────────

resource dataCollectionRule 'Microsoft.Insights/dataCollectionRules@2023-03-11' = {
resource dataCollectionRule 'Microsoft.Insights/dataCollectionRules@2025-05-11' = {
name: dataCollectionRuleName
location: location
kind: 'Direct'
Expand Down Expand Up @@ -272,7 +280,7 @@ resource dataCollectionRule 'Microsoft.Insights/dataCollectionRules@2023-03-11'

// ── Storage Account ──────────────────────────────────────────────────────────

resource storageAccount 'Microsoft.Storage/storageAccounts@2025-01-01' = {
resource storageAccount 'Microsoft.Storage/storageAccounts@2026-06-01' = {
name: storageAccountName
location: location
sku: {
Expand Down Expand Up @@ -313,7 +321,7 @@ resource storageAccount 'Microsoft.Storage/storageAccounts@2025-01-01' = {

// ── Private Endpoint: Storage Account (blob) ─────────────────────────────────

resource storageAccountBlobPrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-10-01' = if (usePrivateEndpoints) {
resource storageAccountBlobPrivateEndpoint 'Microsoft.Network/privateEndpoints@2026-03-01' = if (usePrivateEndpoints) {
name: 'pe-blob-${storageAccountName}'
location: location
properties: any({
Expand Down Expand Up @@ -372,7 +380,7 @@ resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {

// ── Flex Consumption Plan ────────────────────────────────────────────────────

resource flexServicePlan 'Microsoft.Web/serverfarms@2024-11-01' = {
resource flexServicePlan 'Microsoft.Web/serverfarms@2026-07-15' = {
name: 'asp-${functionAppName}'
location: location
kind: 'functionapp'
Expand All @@ -388,7 +396,7 @@ resource flexServicePlan 'Microsoft.Web/serverfarms@2024-11-01' = {

// ── Function App ─────────────────────────────────────────────────────────────

resource functionApp 'Microsoft.Web/sites@2024-11-01' = {
resource functionApp 'Microsoft.Web/sites@2026-07-15' = {
name: functionAppName
location: location
kind: 'functionapp,linux'
Expand Down Expand Up @@ -424,7 +432,7 @@ resource functionApp 'Microsoft.Web/sites@2024-11-01' = {
}
runtime: {
name: 'powerShell'
version: '7.4'
version: '7.6'
}
}
}
Expand All @@ -440,6 +448,8 @@ resource functionApp 'Microsoft.Web/sites@2024-11-01' = {
// Get-Availability configuration — auto-wired from Bicep resources
GETAVAIL_SUBSCRIPTIONS: getavailSubscriptions
GETAVAIL_KINDS: getavailKinds
GETAVAIL_BATCH: getavailBatch ? 'true' : 'false'
GETAVAIL_BATCH_SIZE: string(getavailBatchSize)
DCE_ENDPOINT: dataCollectionEndpoint.properties.logsIngestion.endpoint
DCR_IMMUTABLE_ID: dataCollectionRule.properties.immutableId
SOURCE_WORKSPACE_ID: sourceWorkspaceId
Expand All @@ -456,7 +466,7 @@ resource functionApp 'Microsoft.Web/sites@2024-11-01' = {

// ── Private Endpoint: Function App (sites) ───────────────────────────────────

resource functionAppPrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-10-01' = if (usePrivateEndpoints) {
resource functionAppPrivateEndpoint 'Microsoft.Network/privateEndpoints@2026-03-01' = if (usePrivateEndpoints) {
name: 'pe-sites-${functionAppName}'
location: location
properties: any({
Expand Down
4 changes: 4 additions & 0 deletions Bicep/parameters.dev.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,9 @@ param dnsZonesResourceGroupName = 'rg-alz-dns-hub-itn-001'
// Comma-separated subscription names monitored by the Function App.
param getavailSubscriptions = 'Flaz-Connectivity,Flaz-Management,Flaz-Identity,Flaz-Workloads'

// Use regional batch metric requests, with up to 10 resources per request.
param getavailBatch = true
param getavailBatchSize = 10

// Existing Log Analytics workspace used as the source for Activity Log and Resource Health KQL queries.
param sourceWorkspaceId = 'f25755bb-9b46-4aac-bfae-6a10c4c18440'
2 changes: 1 addition & 1 deletion Functions/GetAvail/RunGetAvailability/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Can also be started manually from the Azure Portal or via the Functions runtime API.

Reads configuration from App Settings (environment variables):
GETAVAIL_SUBSCRIPTIONS - Comma-separated list of subscription names or IDs (required)
GETAVAIL_SUBSCRIPTIONS - Comma-separated list of subscription display names (required)
GETAVAIL_KINDS - Comma-separated resource kinds (default: vm,sql,storage,webapp)
DCE_ENDPOINT - Data Collection Endpoint URL (optional, enables ingestion)
DCR_IMMUTABLE_ID - Data Collection Rule immutable ID (optional, paired with DCE_ENDPOINT)
Expand Down
Loading
Loading