Skip to content

Feature/vpn deployment#57

Open
vgfitzger-microsoft wants to merge 25 commits intomainfrom
feature/VPNDeployment
Open

Feature/vpn deployment#57
vgfitzger-microsoft wants to merge 25 commits intomainfrom
feature/VPNDeployment

Conversation

@vgfitzger-microsoft
Copy link
Collaborator

Refactor to cosmos without mongo api and deploying inside a vnet by default to satisfy security feedback.

Copilot AI review requested due to automatic review settings February 9, 2026 16:35
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 67 out of 67 changed files in this pull request and generated 11 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +8 to +12
<<<<<<< HEAD

@description('List of SQL API container names to provision')
param containerNames array = [
'Users'
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This file still contains unresolved Git merge conflict markers (e.g., <<<<<<< HEAD, =======, >>>>>>>). Bicep compilation will fail until the conflict is resolved and the markers are removed.

Copilot uses AI. Check for mistakes.
infra/main.bicep Outdated
Comment on lines +127 to +132
@description('Enable IP filtering for the web application (when true, only allowedWebIp can access the Container App API)')
<<<<<<< HEAD
param enableWebIpFiltering bool = false
=======
param enableWebIpFiltering bool = true
>>>>>>> origin/main
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Unresolved merge conflict markers are present in this file (e.g., around enableWebIpFiltering and networking params). The template will not compile/apply until these conflicts are resolved and the duplicated/branch-only blocks are removed.

Copilot uses AI. Check for mistakes.
Comment on lines +16 to +20
<<<<<<< HEAD
using Microsoft.Azure.Cosmos;
using System.Text.Json;
=======
>>>>>>> origin/main
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This file contains unresolved merge conflict markers in the using/import section. The project will not build until the conflict is resolved and only the intended imports remain.

Suggested change
<<<<<<< HEAD
using Microsoft.Azure.Cosmos;
using System.Text.Json;
=======
>>>>>>> origin/main
using Microsoft.Azure.Cosmos;
using System.Text.Json;

Copilot uses AI. Check for mistakes.
Comment on lines +264 to +278
builder.Services.AddSingleton(sp =>
{
<<<<<<< HEAD
var dbName = Environment.GetEnvironmentVariable("COSMOSDB_DATABASE")
?? builder.Configuration["CosmosDb:DatabaseName"];

if (string.IsNullOrWhiteSpace(dbName))
{
throw new InvalidOperationException("Cosmos DB database name not found. Set COSMOSDB_DATABASE or CosmosDb:DatabaseName.");
}

return new MedBench.Core.Cosmos.CosmosContainerProvider(
sp.GetRequiredService<CosmosClient>(),
dbName);
=======
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

There is an unresolved merge conflict inside the DI registration for Cosmos/Mongo (starting at <<<<<<< HEAD). Resolve the conflict and remove the MongoDB-based branch entirely if the codebase has migrated to Cosmos SQL API, otherwise the application will not compile.

Copilot uses AI. Check for mistakes.
Comment on lines +122 to +129
// Store Cosmos DB endpoint for managed identity authentication
resource cosmosEndpointSecret 'Microsoft.KeyVault/vaults/secrets@2022-07-01' = {
parent: keyVault
name: 'cosmos-connection-string'
name: 'cosmos-endpoint'
properties: {
value: cosmosAccount.properties.documentEndpoint
}
}
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

cosmosEndpointSecret is defined here, but the file also contains another cosmosEndpointSecret resource later (duplicate declaration). Deployment will fail with a duplicate resource definition; keep only one secret resource for the Cosmos endpoint.

Copilot uses AI. Check for mistakes.
Comment on lines 6 to 10
"name": "bicep",
"version": "0.38.33.27573",
"templateHash": "16783774531187217924"
"templateHash": "3963363190777727422",
}
},
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This JSON is invalid due to a trailing comma after the templateHash property. Remove the trailing comma so infra/main.json parses correctly.

Copilot uses AI. Check for mistakes.
Comment on lines +135 to +140
<<<<<<< HEAD
This project supports two deployment networking modes:

- `DEPLOYMENT_NETWORKING=open` (default): public ingress
- `DEPLOYMENT_NETWORKING=private`: internal-only networking (VNet)

Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This documentation file still contains unresolved Git merge conflict markers (<<<<<<<, =======, >>>>>>>). Resolve the conflict and remove the markers so the rendered docs are correct.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@sashimono-san sashimono-san Feb 16, 2026

Choose a reason for hiding this comment

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

@vgfitzger-microsoft this is a valid one

Comment on lines +15 to +24
with open(path, "r", encoding="utf-8") as f:
content = f.read().strip()
if not content:
return []

if content.startswith("["):
data = json.loads(content)
if not isinstance(data, list):
raise ValueError("Expected a JSON array")
return data
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

_iter_documents reads the entire file into memory to detect JSON-array vs NDJSON, and later docs = list(_iter_documents(...)) materializes everything again. For large exports this can cause high memory usage; consider streaming (peek first non-whitespace char, then iterate items/lines) and upserting incrementally.

Copilot uses AI. Check for mistakes.
Comment on lines +70 to +71
if key in ("$numberDouble", "$numberDecimal"):
return float(inner)
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

Mongo Extended JSON $numberDecimal is converted to float, which can lose precision. Consider using decimal.Decimal (or preserving as string) for $numberDecimal while keeping $numberDouble as float.

Copilot uses AI. Check for mistakes.
Comment on lines +46 to +50
public async Task<DataObject> GetByIdWithIndexAsync(string id)
{
var dataObject = await GetByIdAsync(id);

// Backwards compatibility: populate OriginalDataFile and OriginalIndex if needed
Copy link

Copilot AI Feb 10, 2026

Choose a reason for hiding this comment

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

This GetByIdWithIndexAsync method was added, but the file still contains another GetByIdWithIndexAsync implementation further down (MongoDB-based). The duplicate method signature will prevent compilation; remove/rename the stale implementation so only one method remains.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@sashimono-san sashimono-san left a comment

Choose a reason for hiding this comment

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

I tested the deployment and fixed a few things along the way, please check: #58

Main pending issue is the mismatch between DB and FE admin roles, and the merge conflicts in DEPLOYMENT.md. I left some other comments to consider

Id = Guid.NewGuid().ToString(),
Name = name,
Email = email,
Roles = new List<string> { "Administrator" },
Copy link
Collaborator

Choose a reason for hiding this comment

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

The DB does get populated when env variables are set, but the role itself is different from what the frontend expects, in the FE these pages checks for admin instead of Administrator:

  • Admin.tsx
  • Dashboard.tsx
  • Navigation.tsx
  • AuthContext.tsx

But then, RequireAdministratorRole checks for Administrator.

Comment on lines +63 to 83
deploymentNetworking: "${DEPLOYMENT_NETWORKING=private}"
createVnet: "${CREATE_VNET=true}"
existingVnetResourceId: "${EXISTING_VNET_RESOURCE_ID=}"
existingAcaInfrastructureSubnetId: "${EXISTING_ACA_INFRASTRUCTURE_SUBNET_ID=}"
existingFunctionsIntegrationSubnetId: "${EXISTING_FUNCTIONS_INTEGRATION_SUBNET_ID=}"
vnetAddressSpace: "${VNET_ADDRESS_SPACE=10.30.0.0/16}"
acaInfrastructureSubnetPrefix: "${ACA_INFRASTRUCTURE_SUBNET_PREFIX=10.30.0.0/23}"
functionsIntegrationSubnetPrefix: "${FUNCTIONS_INTEGRATION_SUBNET_PREFIX=10.30.2.0/24}"
gatewaySubnetPrefix: "${GATEWAY_SUBNET_PREFIX=10.30.255.0/27}"
createVpnGateway: "${CREATE_VPN_GATEWAY=true}"
vpnClientAddressPool: "${VPN_CLIENT_ADDRESS_POOL=172.16.200.0/24}"
vpnGatewaySku: "${VPN_GATEWAY_SKU=VpnGw1}"
createPrivateEndpoint: "${CREATE_PRIVATE_ENDPOINT=true}"
privateEndpointSubnetPrefix: "${PRIVATE_ENDPOINT_SUBNET_PREFIX=10.30.4.0/27}"
createDnsResolver: "${CREATE_DNS_RESOLVER=true}"
dnsResolverSubnetPrefix: "${DNS_RESOLVER_SUBNET_PREFIX=10.30.3.0/27}"
dnsResolverInboundIp: "${DNS_RESOLVER_INBOUND_IP=}"
rootAdminEmail: "${ROOT_ADMIN_EMAIL=}"
rootAdminName: "${ROOT_ADMIN_NAME=}"
rootAdminPassword: "${ROOT_ADMIN_PASSWORD=}"
enableWebIpFiltering: "${ENABLE_WEB_IP_FILTERING}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

We have all that under main.parameters.json, and I think having both is redundant.

Comment on lines -47 to -51
hooks:
prepackage:
shell: sh
run: ../../package_addon.sh evaluator
continueOnError: false
Copy link
Collaborator

@sashimono-san sashimono-san Feb 17, 2026

Choose a reason for hiding this comment

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

We still need to run this script, so I added some instructions in the deployment guide (see #58)

#### IP Filtering & Security Configuration

<<<<<<< HEAD
This project supports two deployment networking modes:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Deployments take long, so if possible it's better to have these instructions should come before the Step 3: Deploy the Infrastructure section.

Comment on lines 335 to 348
To start the deployment process, run:

```bash
azd up
```

During deployment you will be prompted for any required variable not yet set, such as subscription, resource group and location.

This command will:
- Provision all Azure infrastructure (Container Apps, Functions, Storage, Cosmos DB, etc.)
- Deploy backend API (with integrated frontend)
- Create or configure Azure OpenAI service
- Set up shared blob storage for all components
- Configure authentication via Entra ID App Registration
Copy link
Collaborator

@sashimono-san sashimono-san Feb 17, 2026

Choose a reason for hiding this comment

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

This section kind of duplicates and extends from section Step 3: Deploy the Infrastructure. When resolving merge conflicts we should merge these two parts of the guide

Comment on lines +107 to +108
> Cosmos DB **local auth is disabled** in this deployment. For local development, run `az login` and ensure your current identity has Cosmos **data-plane** permissions on the target account.
> The API also uses **managed identity / Entra ID** for Storage, so your signed-in identity needs Storage Blob **data-plane** permissions on the target account.
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could add this permission to the user running deployment directly with bicep. I think it would be a nice to have.

Also, the postprovision script is not assigning this data-plane permission. Instead it's assigning the Azure RBAC role for cosmos. See my new PR for this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants