Skip to content

Commit b518ac8

Browse files
fix: address remaining PR 777 copilot comments
1 parent 36d3815 commit b518ac8

3 files changed

Lines changed: 36 additions & 35 deletions

File tree

infra/main.bicep

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ module virtualNetwork 'modules/virtualNetwork.bicep' = if (enablePrivateNetworki
382382
params: {
383383
name: 'vnet-${solutionSuffix}'
384384
addressPrefixes: ['10.0.0.0/20'] // 4096 addresses (enough for 8 /23 subnets or 16 /24)
385-
location: location
385+
location: solutionLocation
386386
deployBastionAndJumpbox: enablePrivateNetworking && deployBastionAndJumpbox
387387
tags: tags
388388
logAnalyticsWorkspaceId: logAnalyticsWorkspaceResourceId
@@ -405,26 +405,28 @@ var zoneSupportedJumpboxLocations = [
405405
'uksouth'
406406
'westus3'
407407
]
408-
var deployAdminAccessResources = enablePrivateNetworking && deployBastionAndJumpbox
408+
var deployAdminAccessResources = enablePrivateNetworking && deployBastionAndJumpbox && !empty(vmAdminPassword)
409409
module bastionHost 'br/public:avm/res/network/bastion-host:0.8.2' = if (deployAdminAccessResources) {
410410
name: take('avm.res.network.bastion-host.${bastionHostName}', 64)
411411
params: {
412412
name: bastionHostName
413413
skuName: 'Standard'
414-
location: location
414+
location: solutionLocation
415415
virtualNetworkResourceId: virtualNetwork!.outputs.resourceId
416-
diagnosticSettings: [
417-
{
418-
name: 'bastionDiagnostics'
419-
workspaceResourceId: logAnalyticsWorkspaceResourceId
420-
logCategoriesAndGroups: [
416+
diagnosticSettings: !empty(logAnalyticsWorkspaceResourceId)
417+
? [
421418
{
422-
categoryGroup: 'allLogs'
423-
enabled: true
419+
name: 'bastionDiagnostics'
420+
workspaceResourceId: logAnalyticsWorkspaceResourceId
421+
logCategoriesAndGroups: [
422+
{
423+
categoryGroup: 'allLogs'
424+
enabled: true
425+
}
426+
]
424427
}
425428
]
426-
}
427-
]
429+
: []
428430
tags: tags
429431
enableTelemetry: enableTelemetry
430432
publicIPAddressObject: {
@@ -434,7 +436,8 @@ module bastionHost 'br/public:avm/res/network/bastion-host:0.8.2' = if (deployAd
434436
}
435437

436438
// Jumpbox Virtual Machine
437-
var jumpboxVmName = take('vm-jumpbox-${solutionSuffix}', 15)
439+
var jumpboxUniqueToken = take(uniqueString(resourceGroup().id, solutionSuffix), 10)
440+
var jumpboxVmName = take('vm-${jumpboxUniqueToken}', 15)
438441
module jumpboxVM 'br/public:avm/res/compute/virtual-machine:0.21.0' = if (deployAdminAccessResources) {
439442
name: take('avm.res.compute.virtual-machine.${jumpboxVmName}', 64)
440443
params: {

infra/main.json

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.41.2.15936",
9-
"templateHash": "876801466335750099"
9+
"templateHash": "690774053853233065"
1010
},
1111
"name": "Intelligent Content Generation Accelerator",
1212
"description": "Solution Accelerator for multimodal marketing content generation using Microsoft Agent Framework.\n"
@@ -358,8 +358,9 @@
358358
"uksouth",
359359
"westus3"
360360
],
361-
"deployAdminAccessResources": "[and(parameters('enablePrivateNetworking'), parameters('deployBastionAndJumpbox'))]",
362-
"jumpboxVmName": "[take(format('vm-jumpbox-{0}', variables('solutionSuffix')), 15)]",
361+
"deployAdminAccessResources": "[and(and(parameters('enablePrivateNetworking'), parameters('deployBastionAndJumpbox')), not(empty(parameters('vmAdminPassword'))))]",
362+
"jumpboxUniqueToken": "[take(uniqueString(resourceGroup().id, variables('solutionSuffix')), 10)]",
363+
"jumpboxVmName": "[take(format('vm-{0}', variables('jumpboxUniqueToken')), 15)]",
363364
"privateDnsZones": [
364365
"privatelink.cognitiveservices.azure.com",
365366
"privatelink.openai.azure.com",
@@ -4856,7 +4857,7 @@
48564857
]
48574858
},
48584859
"location": {
4859-
"value": "[parameters('location')]"
4860+
"value": "[variables('solutionLocation')]"
48604861
},
48614862
"deployBastionAndJumpbox": {
48624863
"value": "[and(parameters('enablePrivateNetworking'), parameters('deployBastionAndJumpbox'))]"
@@ -7443,25 +7444,12 @@
74437444
"value": "Standard"
74447445
},
74457446
"location": {
7446-
"value": "[parameters('location')]"
7447+
"value": "[variables('solutionLocation')]"
74477448
},
74487449
"virtualNetworkResourceId": {
74497450
"value": "[reference('virtualNetwork').outputs.resourceId.value]"
74507451
},
7451-
"diagnosticSettings": {
7452-
"value": [
7453-
{
7454-
"name": "bastionDiagnostics",
7455-
"workspaceResourceId": "[if(variables('useExistingLogAnalytics'), parameters('existingLogAnalyticsWorkspaceId'), if(parameters('enableMonitoring'), reference('logAnalyticsWorkspace').outputs.resourceId.value, ''))]",
7456-
"logCategoriesAndGroups": [
7457-
{
7458-
"categoryGroup": "allLogs",
7459-
"enabled": true
7460-
}
7461-
]
7462-
}
7463-
]
7464-
},
7452+
"diagnosticSettings": "[if(not(empty(if(variables('useExistingLogAnalytics'), parameters('existingLogAnalyticsWorkspaceId'), if(parameters('enableMonitoring'), reference('logAnalyticsWorkspace').outputs.resourceId.value, '')))), createObject('value', createArray(createObject('name', 'bastionDiagnostics', 'workspaceResourceId', if(variables('useExistingLogAnalytics'), parameters('existingLogAnalyticsWorkspaceId'), if(parameters('enableMonitoring'), reference('logAnalyticsWorkspace').outputs.resourceId.value, '')), 'logCategoriesAndGroups', createArray(createObject('categoryGroup', 'allLogs', 'enabled', true()))))), createObject('value', createArray()))]",
74657453
"tags": {
74667454
"value": "[parameters('tags')]"
74677455
},
@@ -24873,8 +24861,8 @@
2487324861
},
2487424862
"dependsOn": [
2487524863
"aiFoundryAiServices",
24876-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
2487724864
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
24865+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
2487824866
"virtualNetwork"
2487924867
]
2488024868
},

src/backend/event_utils.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
import os
2+
import logging
23
from azure.monitor.events.extension import track_event
34

5+
logger = logging.getLogger(__name__)
6+
_telemetry_disabled_logged = False
7+
48

59
def track_event_if_configured(event_name: str, event_data: dict):
10+
global _telemetry_disabled_logged
611
connection_string = os.getenv("APPLICATIONINSIGHTS_CONNECTION_STRING")
7-
if connection_string:
8-
track_event(event_name, event_data)
12+
if not connection_string:
13+
if not _telemetry_disabled_logged:
14+
logger.warning("Application Insights connection string is not set; telemetry events are disabled.")
15+
_telemetry_disabled_logged = True
16+
return
17+
18+
track_event(event_name, event_data)

0 commit comments

Comments
 (0)