Skip to content

Fix McpWeatherApp deployment: infra, prepackage hook, and file resolution#25

Open
ahmedmuhsin wants to merge 3 commits intoAzure-Samples:mainfrom
ahmedmuhsin:weather-app-deploy-fix
Open

Fix McpWeatherApp deployment: infra, prepackage hook, and file resolution#25
ahmedmuhsin wants to merge 3 commits intoAzure-Samples:mainfrom
ahmedmuhsin:weather-app-deploy-fix

Conversation

@ahmedmuhsin
Copy link
Copy Markdown
Contributor

@ahmedmuhsin ahmedmuhsin commented Apr 21, 2026

Fix McpWeatherApp deployment: infra, prepackage hook, and file resolution

This PR fixes the McpWeatherApp sample so it works both locally and when deployed to Azure via azd up.

Problems Fixed

  1. No infrastructure for weather service – The Bicep only provisioned one function app (api), but azure.yaml defines a weather service. Added a separate Flex Consumption plan and function app for the weather service (Flex Consumption allows only one site per plan).

  2. UI not built during deploymentazd deploy runs mvn package but the Vite UI (app/dist/index.html) was never built, so the resource endpoint returned "Widget not found". Added a prepackage hook in azure.yaml that runs npm install and npm run build before Maven packaging.

  3. File not found on Azure – The widget code used a CWD-relative file path. On Azure Flex Consumption, the CWD differs from the function app root, so the file was never found. Fixed to resolve the path relative to the jar location.

  4. Remote MCP auth – Updated mcp.json to accept a system key for authenticated remote MCP connections.

Testing

  • Local: All MCP endpoints verified (initialize, tools/list, tools/call, resources/list, resources/read)
  • Remote (Azure): All endpoints verified after deployment via azd deploy
  • VS Code Copilot: Both local and remote MCP servers connected and invoked successfully

… jar-relative file resolution

- Add separate Flex Consumption plan and function app for weather service in main.bicep
- Add FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI staging CDN setting for MCP extension
- Add prepackage hook in azure.yaml to run npm build before Maven packaging
- Fix WeatherFunction.java to resolve app/dist/index.html relative to jar location (required on Azure where CWD differs from function root)
- Update mcp.json to support system key for remote MCP endpoint
Copilot AI review requested due to automatic review settings April 21, 2026 16:23
Copy link
Copy Markdown

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

Fixes the McpWeatherApp sample’s local + azd up Azure deployment by aligning infra/resources with azure.yaml, ensuring the UI is built during deployment, and making UI file resolution work under Azure Functions Flex Consumption.

Changes:

  • Adds a dedicated Flex Consumption plan + Function App for the weather service and required storage container + outputs.
  • Adds an azd prepackage hook to build the Vite UI before Maven packaging.
  • Updates the widget resource handler to resolve app/dist/index.html relative to the deployed artifact location (with local fallbacks), and updates remote MCP config to accept a system key.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
samples/McpWeatherApp/src/main/java/com/function/weather/WeatherFunction.java Adjusts widget HTML resolution to work on Azure where CWD differs.
infra/main.bicep Provisions separate weather Function App + plan, adds staging extension bundle setting, storage container, and output.
azure.yaml Adds a prepackage hook for weather service to build the UI before mvn package.
.vscode/mcp.json Prompts for a system key and appends it to the remote MCP webhook URL.

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

Comment thread infra/main.bicep Outdated
Comment thread azure.yaml Outdated
Extension bundle 4.32.0 with MCP support is already published to the
production CDN (identical zip on both CDNs), so the staging override
is no longer needed.
…wsh hook

- Split try/catch in WeatherFunction.java to separate path resolution
  from file read, with distinct error messages for each
- Wrap function app names in toLower() for storage container names to
  avoid invalid mixed-case container names
- Use && instead of ; in Windows pwsh prepackage hook so failures
  propagate correctly
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.

2 participants