Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 19, 2025

Fix for func pack --build-native-deps failing on Windows with Python 3.13+

Problem

The Docker image name azure-functions/python:4-python3.13-buildenv contains a colon (:) which is invalid in Windows file paths. When the code tries to create a temporary directory using this image name, it fails on Windows.

Plan

  • Understand the codebase and identify the issue location
  • Fix PythonHelpers.cs to sanitize the image name when using it as a directory path
  • Add unit tests to verify the fix works on Windows
  • Build and test the changes
  • Run code review
  • Run security checks

Technical Details

The issue is in PythonHelpers.ChoosePythonBuildEnvImage() method where:

  • Line 567: image = $"azure-functions/python:4-python{workerInfo.Major}.{workerInfo.Minor}-buildenv"
  • Line 570: string tempDockerfileDirecotry = Path.Combine(Path.GetTempPath(), $"{image}-docker")

The fix will replace colons with a safe character (like hyphen) when creating the directory path, while keeping the actual Docker image name unchanged.

Original prompt

This section details on the original issue you should resolve

<issue_title>func pack --build-native-deps fails for Python 3.13+ when running on Windows</issue_title>
<issue_description>### Version

4.4.0+

Description

Running func pack --build-native-deps for Python 3.13+ on a Windows machine throws an error saying that:

The directory name is invalid. : 'C:\Users\victoriahall\AppData\Local\Temp\azure-functions\python:4-python3.13-buildenv-docker'

I also tested with CT version 4.5.0 and got the same error. This only seems to happen with Windows - Mac seems to work as expected.

Full output:

(.venv313) PS C:\Users\victoriahall\Documents\repos\sdk-servicebus> func pack --build-native-deps
'local.settings.json' found in root directory (C:\Users\victoriahall\Documents\repos\sdk-servicebus).
Resolving worker runtime to 'python'.
'local.settings.json' found in root directory (C:\Users\victoriahall\Documents\repos\sdk-servicebus).
Resolving worker runtime to 'python'.

Validating project...

  Validate host.json: PASSED
  Validate Flag Compatibility: PASSED
  Validate Folder Structure: PASSED
  Validation .python_packages directory exists: WARNING
    Directory '.python_packages' not found or is empty.
  Validate Python Programming Model: PASSED

The directory name is invalid. : 'C:\Users\victoriahall\AppData\Local\Temp\azure-functions\python:4-python3.13-buildenv-docker'
(.venv313) PS C:\Users\victoriahall\Documents\repos\sdk-servicebus> func --version
4.4.0

Steps to reproduce

  1. On a Windows machine, download Python 3.13 & create a 3.13 environment
  2. Start Docker
  3. Run func pack --build-native-deps in the terminal</issue_description>

<agent_instructions>In PythonHelpers, we set the image name to have a : in it, which is also used as the filename for the temp dockerfile. : is not an acceptable file name on windows machines so we should fix this by either removing the : or haveing a different filename to the image name</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@liliankasem Thanks for catching this! The colon is acceptable in osx filepath but not in windows - should be an easy fix to update the filepath for the temp dockerfile. Will make sure to test on a windows machine :)

💡 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.

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.

func pack --build-native-deps fails for Python 3.13+ when running on Windows

2 participants