Add automatic remote build detection for Python apps in func pack command #4530
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements automatic remote build detection for the
func pack
command when running Python function apps on Windows machines that target Linux environments. This addresses the cross-platform scenario where Python dependencies need to be built for the correct target platform.Problem
Previously, the
func pack
command always used local builds regardless of the development platform, which could cause issues when:requirements.txt
contain native code that needs to be compiled for LinuxThis resulted in Windows-compiled dependencies being packaged, which would fail when deployed to Linux-based Azure Functions.
Solution
Extended the existing remote build detection logic from the
func azure functionapp publish
command to thefunc pack
command:Changes Made
PackAction.cs: Modified to automatically resolve build options instead of using hardcoded
BuildOption.Default
PublishHelper.cs: Enhanced
ResolveBuildOption
method to detect cross-platform scenariosBehavior
The
func pack
command will now automatically use remote build when:requirements.txt
exists and has contentAll other scenarios maintain existing behavior:
requirements.txt
→ Default buildrequirements.txt
→ Default build--no-build
or--build-native-deps
flags → Respect user choiceTesting
Added comprehensive unit tests covering:
requirements.txt
Benefits
func azure functionapp publish
Fixes #4255.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
azfunc.pkgs.visualstudio.com
dotnet build
(dns block)/home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js
(dns block)dotnet restore src/Cli/func/Azure.Functions.Cli.csproj
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.