From 25bf09b80fd5d3c8e79f309c6dfdb044d47822a3 Mon Sep 17 00:00:00 2001 From: Manvir Kaur <67894494+manvkaur@users.noreply.github.com> Date: Tue, 17 Nov 2026 16:35:25 -0800 Subject: [PATCH 1/3] Default travel planner frontend to Static Web App /api route Production builds now call the linked Static Web App backend at /api when VITE_API_URL is unset, while local development still defaults to http://localhost:7071/api. Update README instructions from REACT_APP_API_URL to VITE_API_URL. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../AiAgentTravelPlanOrchestrator/Frontend/README.md | 6 +++--- .../Frontend/src/components/ChatInterface.jsx | 3 ++- .../dotnet/AiAgentTravelPlanOrchestrator/README.md | 10 +++++----- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/README.md b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/README.md index 09b937a6..8007fe54 100644 --- a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/README.md +++ b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/README.md @@ -59,7 +59,7 @@ Locally preview the production build. ## Environment Variables -Create a `.env` file for local development or `.env.production` for production builds: +Create a `.env` file for local development or `.env.production` to override the production API endpoint: ```env VITE_API_URL=http://localhost:7071/api @@ -67,7 +67,7 @@ VITE_API_URL=http://localhost:7071/api | Variable | Description | Default | |----------|-------------|---------| -| `VITE_API_URL` | Backend API endpoint URL | `http://localhost:7071/api` | +| `VITE_API_URL` | Backend API endpoint URL | Local development: `http://localhost:7071/api`; production: `/api` | ## Local Development @@ -93,7 +93,7 @@ VITE_API_URL=http://localhost:7071/api 4. **Ensure the backend is running**: - The frontend expects the Azure Functions backend to be running at the configured `VITE_API_URL`. + The frontend defaults to the local Azure Functions endpoint. In production, it defaults to `/api`, which the linked Static Web App backend routes to Azure Functions. ## Deployment diff --git a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/src/components/ChatInterface.jsx b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/src/components/ChatInterface.jsx index dbc69293..2b3d02a6 100644 --- a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/src/components/ChatInterface.jsx +++ b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/Frontend/src/components/ChatInterface.jsx @@ -6,7 +6,8 @@ import ProgressTracker from './ProgressTracker'; import './progress-tracker.css'; // Get API URL from environment variables -const API_URL = import.meta.env.VITE_API_URL || 'http://localhost:7071/api'; +const API_URL = import.meta.env.VITE_API_URL + || (import.meta.env.DEV ? 'http://localhost:7071/api' : '/api'); const ChatInterface = () => { // Travel request state diff --git a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md index 339a86b7..ce19cf54 100644 --- a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md +++ b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md @@ -312,15 +312,15 @@ azd provision ### 6. Deploy React Web App -Update your `.env.production` file in `Frontend` directory so that it points to the correct API endpoint. +The deployed frontend uses the Static Web App's linked Function App backend at `/api` by default. To override this, set `VITE_API_URL` in `Frontend/.env.production` to the desired API endpoint. #### Bash ```bash STATIC_WEB_APP_URI=$(azd env get-value STATIC_WEB_APP_URI) -echo "REACT_APP_API_URL=$STATIC_WEB_APP_URI/api" > ./Frontend/.env.production +echo "VITE_API_URL=$STATIC_WEB_APP_URI/api" > ./Frontend/.env.production -# Redeploy the build bundle. +# Redeploy the build bundle. azd package web azd deploy web ``` @@ -329,9 +329,9 @@ azd deploy web ```PowerShell $staticWebAppUri = azd env get-value STATIC_WEB_APP_URI -"REACT_APP_API_URL=$staticWebAppUri/api" | Out-File -FilePath "./Frontend/.env.production" -Encoding utf8 +"VITE_API_URL=$staticWebAppUri/api" | Out-File -FilePath "./Frontend/.env.production" -Encoding utf8 -# Redeploy the build bundle. +# Redeploy the build bundle. azd package web azd deploy web ``` From db064ef4b923debbfb1af6ae19097c1079b948d1 Mon Sep 17 00:00:00 2001 From: Manvir Kaur <67894494+manvkaur@users.noreply.github.com> Date: Tue, 17 Nov 2026 21:46:53 -0800 Subject: [PATCH 2/3] Fix travel planner Bicep build warnings Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../infra/core/host/functions-app.bicep | 12 ++++++---- .../infra/main.bicep | 23 ++++--------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/core/host/functions-app.bicep b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/core/host/functions-app.bicep index 9eb0c69c..443b6d3a 100644 --- a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/core/host/functions-app.bicep +++ b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/core/host/functions-app.bicep @@ -39,7 +39,8 @@ module functions 'br/public:avm/res/web/site:0.16.0' = { tags: tags serverFarmResourceId: appServicePlanId managedIdentities: { - userAssignedResourceIds: [identityId] + systemAssigned: identityType == 'SystemAssigned' + userAssignedResourceIds: identityType == 'UserAssigned' ? [identityId] : [] } siteConfig: { netFrameworkVersion: 'v10.0' @@ -61,9 +62,11 @@ module functions 'br/public:avm/res/web/site:0.16.0' = { FUNCTIONS_WORKER_RUNTIME: 'dotnet-isolated' AzureWebJobsStorage__accountName: storageAccount.name AzureWebJobsStorage__credential : 'managedidentity' - APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights.properties.ConnectionString WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED: '1' - }) + }, + !empty(applicationInsightsName) ? { + APPLICATIONINSIGHTS_CONNECTION_STRING: applicationInsights!.properties.ConnectionString + } : {}) } ] } @@ -71,5 +74,6 @@ module functions 'br/public:avm/res/web/site:0.16.0' = { output name string = functions.outputs.name output uri string = 'https://${functions.outputs.defaultHostname}' -output identityPrincipalId string = identityType == 'SystemAssigned' ? functions.outputs.systemAssignedMIPrincipalId : '' +// A system-assigned identity is deployed whenever this output is needed. +output identityPrincipalId string = identityType == 'SystemAssigned' ? functions.outputs.systemAssignedMIPrincipalId! : '' output id string = functions.outputs.resourceId diff --git a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/main.bicep b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/main.bicep index 888abbae..648330bf 100644 --- a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/main.bicep +++ b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/infra/main.bicep @@ -187,9 +187,9 @@ module api './app/api.bicep' = { appSettings: { // https://learn.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-configure-managed-identity // These would be needed if running outside of cloud - AzureWebJobsStorage__blobServiceUri: 'https://${storage.outputs.name}.blob.core.windows.net' - AzureWebJobsStorage__queueServiceUri: 'https://${storage.outputs.name}.queue.core.windows.net' - AzureWebJobsStorage__tableServiceUri: 'https://${storage.outputs.name}.blob.core.windows.net' + AzureWebJobsStorage__blobServiceUri: storage.outputs.primaryEndpoints.blob + AzureWebJobsStorage__queueServiceUri: storage.outputs.primaryEndpoints.queue + AzureWebJobsStorage__tableServiceUri: storage.outputs.primaryEndpoints.table AZURE_TENANT_ID: tenant().tenantId AZURE_CLIENT_ID: apiUserAssignedIdentity.outputs.identityClientId DURABLE_TASK_SCHEDULER_CONNECTION_STRING: 'Endpoint=${dts.outputs.dts_URL};Authentication=ManagedIdentity;ClientID=${apiUserAssignedIdentity.outputs.identityClientId}' @@ -201,13 +201,8 @@ module api './app/api.bicep' = { ITINERARY_PLANNER_AGENT_ID: itineraryPlannerAgentId LOCAL_RECOMMENDATIONS_AGENT_ID: localRecommendationsAgentId } - virtualNetworkSubnetId: skipVnet ? '' : serviceVirtualNetwork.outputs.appSubnetID + virtualNetworkSubnetId: skipVnet ? '' : serviceVirtualNetwork!.outputs.appSubnetID } - dependsOn: [ - storage - appServicePlan - apiUserAssignedIdentity - ] } // Microsoft Foundry resource, project, and model deployment used by the agents @@ -337,7 +332,7 @@ module storagePrivateEndpoint 'app/storage-private-endpoint.bicep' = if (!skipVn location: location tags: tags virtualNetworkName: !empty(vNetName) ? vNetName : '${abbrs.networkVirtualNetworks}${resourceToken}' - subnetName: skipVnet ? '' : serviceVirtualNetwork.outputs.peSubnetName + subnetName: skipVnet ? '' : serviceVirtualNetwork!.outputs.peSubnetName resourceName: storage.outputs.name } } @@ -366,9 +361,6 @@ module appInsightsRoleAssignmentApi './core/monitor/appinsights-access.bicep' = roleDefinitionID: monitoringRoleDefinitionId principalID: apiUserAssignedIdentity.outputs.identityPrincipalId } - dependsOn: [ - apiUserAssignedIdentity - ] } var durableTaskDataContributorRoleDefinitionId = '0ad04412-c4d5-4796-b79c-f76d14c8d402' @@ -385,8 +377,6 @@ module dtsRoleAssignment 'app/dts-Access.bicep' = { } dependsOn: [ storage - apiUserAssignedIdentity - dts ] } @@ -399,9 +389,6 @@ module dtsDashboardRoleAssignment 'app/dts-Access.bicep' = { principalType: 'User' dtsName: dts.outputs.dts_NAME } - dependsOn: [ - dts - ] } module dts './app/dts.bicep' = { From af1e1cc5eae882159d78dbea9276e6a09d18949c Mon Sep 17 00:00:00 2001 From: Manvir Kaur <67894494+manvkaur@users.noreply.github.com> Date: Tue, 17 Nov 2026 21:55:48 -0800 Subject: [PATCH 3/3] Document travel planner deployment and local setup Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- .../AiAgentTravelPlanOrchestrator/README.md | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md index ce19cf54..ae6df874 100644 --- a/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md +++ b/samples/durable-functions/dotnet/AiAgentTravelPlanOrchestrator/README.md @@ -132,7 +132,7 @@ Create a `local.settings.json` file in the root directory with the following con "LOCAL_RECOMMENDATIONS_AGENT_ID": "" }, "Host": { - "LocalHttpPort": 7252, + "LocalHttpPort": 7071, "CORS": "*", "CORSCredentials": false } @@ -175,7 +175,7 @@ npm install npm start ``` -The application will be accessible at `http://localhost:3000` +The application will be accessible at `http://localhost:3000`. In development, the frontend calls `http://localhost:7071/api` by default. If you run the Functions host on a different port, create `Frontend/.env` with `VITE_API_URL=http://localhost:/api`. ## Deploying to Azure @@ -222,9 +222,19 @@ Follow the prompts to configure your environment settings. ### 3. Provision Resources and Deploy -Use the Azure Developer CLI to provision all necessary resources and deploy your application: +Use the Azure Developer CLI to provision all necessary resources and deploy your application. Set `SWA_CLI_DEPLOY_ENV=production` first so the frontend deploys to the Static Web App production environment, where the linked backend is available (see the note in [step 6](#6-deploy-react-web-app)). + +#### Bash ```bash +export SWA_CLI_DEPLOY_ENV=production +azd up +``` + +#### PowerShell + +```PowerShell +$env:SWA_CLI_DEPLOY_ENV = "production" azd up ``` @@ -314,26 +324,21 @@ azd provision The deployed frontend uses the Static Web App's linked Function App backend at `/api` by default. To override this, set `VITE_API_URL` in `Frontend/.env.production` to the desired API endpoint. +> [!IMPORTANT] +> With azd 1.33 and Static Web Apps CLI 2.1, `azd deploy web` deployed the frontend to a preview environment that doesn't have the linked backend, so `/api` calls failed. Setting `SWA_CLI_DEPLOY_ENV=production` before deploying sent the frontend to the production environment, where the linked backend is available. This workaround was tested with `azd deploy --all`; it hasn't been verified as part of a complete `azd up` run. If the variable isn't set in your current shell, set it again before deploying. + #### Bash ```bash -STATIC_WEB_APP_URI=$(azd env get-value STATIC_WEB_APP_URI) -echo "VITE_API_URL=$STATIC_WEB_APP_URI/api" > ./Frontend/.env.production - -# Redeploy the build bundle. -azd package web -azd deploy web +export SWA_CLI_DEPLOY_ENV=production +azd deploy --all ``` #### PowerShell ```PowerShell -$staticWebAppUri = azd env get-value STATIC_WEB_APP_URI -"VITE_API_URL=$staticWebAppUri/api" | Out-File -FilePath "./Frontend/.env.production" -Encoding utf8 - -# Redeploy the build bundle. -azd package web -azd deploy web +$env:SWA_CLI_DEPLOY_ENV = "production" +azd deploy --all ``` ## Clean up