Skip to content

Commit 7467d92

Browse files
committed
Address feedback from Copilot
1 parent 58afb4c commit 7467d92

File tree

9 files changed

+48
-9
lines changed

9 files changed

+48
-9
lines changed

.dockerignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,14 @@
22
.venv
33
.logfire
44
.devcontainer
5+
infra
6+
7+
# Common Python and development files to exclude
8+
__pycache__
9+
*.pyc
10+
*.pyo
11+
*.egg-info
12+
.pytest_cache
13+
.ruff_cache
14+
.env
15+
.git

agents/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ COPY --from=ghcr.io/astral-sh/uv:0.9.14 /uv /uvx /bin/
1414
WORKDIR /code
1515

1616
# Copy dependency files and install dependencies (for layer caching)
17-
# Note: We avoid --mount=type=cache since Azure Container Apps remote build doesn't support BuildKit
17+
# Note: We can't use --mount=type=cache since Azure Container Apps remote build doesn't support BuildKit:
18+
# https://github.com/Azure/acr/issues/721
1819
COPY uv.lock pyproject.toml ./
1920
RUN uv sync --locked --no-install-project
2021

infra/core/host/container-apps.bicep

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ param subnetResourceId string = ''
1515

1616
param usePrivateIngress bool = true
1717

18+
param usePrivateAcr bool = false
19+
1820
module containerAppsEnvironment 'container-apps-environment.bicep' = {
1921
name: '${name}-container-apps-environment'
2022
params: {
@@ -36,6 +38,7 @@ module containerRegistry 'container-registry.bicep' = {
3638
location: location
3739
tags: tags
3840
useVnet: !empty(vnetName)
41+
usePrivateAcr: usePrivateAcr
3942
}
4043
}
4144

infra/core/host/container-registry.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ param encryption object = {
1010
status: 'disabled'
1111
}
1212
param networkRuleBypassOptions string = 'AzureServices'
13-
param publicNetworkAccess string = 'Enabled' // Keep public access enabled for pushing images from local machine
1413
param useVnet bool = false // Determines if VNet integration is enabled
14+
param usePrivateAcr bool = false // Determines if public network access should be disabled
1515
param sku object = {
1616
name: useVnet ? 'Premium' : 'Standard' // Use Premium if VNet is required, otherwise Standard
1717
}
@@ -32,7 +32,7 @@ resource containerRegistry 'Microsoft.ContainerRegistry/registries@2022-02-01-pr
3232
dataEndpointEnabled: dataEndpointEnabled
3333
encryption: encryption
3434
networkRuleBypassOptions: networkRuleBypassOptions
35-
publicNetworkAccess: publicNetworkAccess
35+
publicNetworkAccess: usePrivateAcr ? 'Disabled' : 'Enabled'
3636
zoneRedundancy: zoneRedundancy
3737
}
3838
}

infra/main.bicep

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ param useVnet bool = false
4646
@description('Flag to enable or disable public ingress')
4747
param usePrivateIngress bool = false
4848

49+
@description('Flag to restrict ACR public network access (requires VPN for local image push when true)')
50+
param usePrivateAcr bool = false
51+
52+
@description('Flag to restrict Log Analytics public query access for increased security')
53+
param usePrivateLogAnalytics bool = false
54+
4955
var resourceToken = toLower(uniqueString(subscription().id, name, location))
5056
var tags = { 'azd-env-name': name }
5157

@@ -152,7 +158,7 @@ module logAnalyticsWorkspace 'br/public:avm/res/operational-insights/workspace:0
152158
skuName: 'PerGB2018'
153159
dataRetention: 30
154160
publicNetworkAccessForIngestion: useVnet ? 'Disabled' : 'Enabled'
155-
publicNetworkAccessForQuery: 'Enabled' // Keep public query access for debugging - change to 'Disabled' for more security
161+
publicNetworkAccessForQuery: usePrivateLogAnalytics ? 'Disabled' : 'Enabled'
156162
useResourcePermissions: true
157163
}
158164
}
@@ -554,7 +560,7 @@ module monitorPrivateLinkScope 'br/public:avm/res/insights/private-link-scope:0.
554560
tags: tags
555561
accessModeSettings: {
556562
ingestionAccessMode: 'PrivateOnly'
557-
queryAccessMode: 'Open' // Allow public queries for debugging - change to 'PrivateOnly' for more security
563+
queryAccessMode: usePrivateLogAnalytics ? 'PrivateOnly' : 'Open'
558564
}
559565
scopedResources: [
560566
{
@@ -606,6 +612,7 @@ module containerApps 'core/host/container-apps.bicep' = {
606612
vnetName: useVnet ? virtualNetwork!.outputs.name : ''
607613
subnetName: useVnet ? virtualNetwork!.outputs.subnetNames[0] : ''
608614
usePrivateIngress: usePrivateIngress
615+
usePrivateAcr: usePrivateAcr
609616
}
610617
}
611618

infra/main.parameters.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@
2020
"usePrivateIngress": {
2121
"value": "${USE_PRIVATE_INGRESS=false}"
2222
},
23+
"usePrivateAcr": {
24+
"value": "${USE_PRIVATE_ACR=false}"
25+
},
26+
"usePrivateLogAnalytics": {
27+
"value": "${USE_PRIVATE_LOGANALYTICS=false}"
28+
},
2329
"serverExists": {
2430
"value": "${SERVICE_SERVER_RESOURCE_EXISTS=false}"
2531
},

infra/server.bicep

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ module app 'core/host/container-app-upsert.bicep' = {
7474
path: '/health'
7575
port: 8000
7676
}
77-
initialDelaySeconds: 3
77+
initialDelaySeconds: 10
7878
periodSeconds: 3
79-
failureThreshold: 30
79+
failureThreshold: 60
8080
}
8181
{
8282
type: 'Readiness'

servers/Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ COPY --from=ghcr.io/astral-sh/uv:0.9.14 /uv /uvx /bin/
1414
WORKDIR /code
1515

1616
# Copy dependency files and install dependencies (for layer caching)
17-
# Note: We avoid --mount=type=cache since Azure Container Apps remote build doesn't support BuildKit
17+
# Note: We can't use --mount=type=cache since Azure Container Apps remote build doesn't support BuildKit:
18+
# https://github.com/Azure/acr/issues/721
1819
COPY uv.lock pyproject.toml ./
1920
RUN uv sync --locked --no-install-project
2021

servers/deployed_mcp.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,17 @@
6666

6767

6868
@mcp.custom_route("/health", methods=["GET"])
69-
async def health_check(request):
69+
async def health_check(_request):
70+
"""
71+
Health check endpoint for service availability.
72+
73+
This endpoint is used by Azure Container Apps health probes to verify that the service is running.
74+
Returns a JSON response with the following format:
75+
{
76+
"status": "healthy",
77+
"service": "mcp-server"
78+
}
79+
"""
7080
return JSONResponse({"status": "healthy", "service": "mcp-server"})
7181

7282

0 commit comments

Comments
 (0)