azure-functions-core-tools icon indicating copy to clipboard operation
azure-functions-core-tools copied to clipboard

Clarify 'func pack'

Open matiaslahticgi opened this issue 6 years ago • 13 comments

Running func pack seems to be the only way to replicate what func azure functionapp publish does to get a .zip file ready to deploy (for example in Azure DevOps pipelines).

However, func pack is not documented anywhere as far as I can see, mostly mentioned in random GitHub issues or ending up looking at azure-functions-pack (aka funcpack) which seems to be a deprecated webpack recipe, eg. not relevant.

My question is if func pack is the recommended way to pack (Python) Function Apps and if so, is it documented anywhere? For example, I would like to choose the name for the .zip myself.

If func pack is not the recommended way to produce a deployable .zip, what is the recommended way?

matiaslahticgi avatar Mar 21 '19 11:03 matiaslahticgi

@asavaritayal to comment

ahmedelnably avatar Mar 21 '19 17:03 ahmedelnably

@matiaslahticgi can you elaborate on the requirement for your scenario?

So far, func pack has only been an internal facing utility. It would be helpful to understand if there are any cases where the user directly needs to interact with the command. For devops, we generally recommend using the pipeline here - https://github.com/Azure/azure-functions-devops-build/blob/master/sample_yaml_builds/linux/consumption/python-consumption.yml

asavaritayal avatar Mar 22 '19 07:03 asavaritayal

Well, I would like to have a single, self-updating and correct way of building the package rather than copypasting a template to the pipeline that then needs to be kept up to date (eg. will definitely go out of date at some point, causing builds to fail etc)..

Does func pack, then, essentially just do what the build template does, eg:

dotnet restore # COMMENT OUT IF NOT USING FUNCTION EXTENSIONS
dotnet build --runtime ubuntu.16.04-x64 --output './bin/' # COMMENT OUT IF NOT USING FUNCTION EXTENSIONS
python3.6 -m venv worker_venv
source worker_venv/bin/activate
pip3.6 install setuptools
pip3.6 install -r requirements.txt

And what is the difference to this when running func pack --build-native-deps (we're using this currently to push in binary wheels)?

All in all I find the build process rather opaque which is a bit problematic when the use case is something more complex than what the starter tutorials involve, especially when it relates to handling Python modules and interfacing with other, non-Python libraries. Documenting it would be an awesome start, as currently all my knowledge of it comes from inspecting scripts, inspecting temporary files etc.

matiaslahticgi avatar Mar 22 '19 07:03 matiaslahticgi

we should add it to the docs. The only reason I didn't was because I wasn't sure about the name pack due to the possible confusion with that other tool you linked to above.

ahmelsayed avatar Mar 22 '19 21:03 ahmelsayed

Any updates here?

tbarlow12 avatar Sep 23 '19 15:09 tbarlow12

We'd like to use func pack as the packaging piece of the lifecycle for the Azure Functions plugin to the Serverless Framework.

tbarlow12 avatar Sep 23 '19 16:09 tbarlow12

This, in conjunction with https://github.com/Azure/azure-functions-core-tools/issues/1589 would be of great value to our team

TylerHaigh avatar Oct 20 '19 03:10 TylerHaigh

Any news? I'm trying to figure out The way to deploy azure function app in python from azure devops pipelines I would like something that can apply .funcignore Still it looks like the only way is core tools installation on a build agent and "func pack"

So please, provide some docs and consider changing status of this function from "internal" to public and maintained so devops folks could sleep well

Thanks

P. S. Just realized: this ticket is 4 years old. All we're asking is documenting one function.

poddubitskya avatar Jul 21 '23 09:07 poddubitskya

Any news? I'm trying to figure out The way to deploy azure function app in python from azure devops pipelines I would like something that can apply .funcignore Still it looks like the only way is core tools installation on a build agent and "func pack"

So please, provide some docs and consider changing status of this function from "internal" to public and maintained so devops folks could sleep well

Thanks

P. S. Just realized: this ticket is 4 years old. All we're asking is documenting one function.

https://github.com/Azure/azure-functions-core-tools/blob/bb99b697da863b2dc4181316d68fc971ae3d54e0/src/Azure.Functions.Cli/Actions/LocalActions/PackAction.cs#L18

Usage: [command] [options] [arguments]

Options:
  -o, --output <path>                 output path for the packed archive
      --build-native-deps            Skips generating .wheels folder when publishing python function apps. (default: false)
      --no-bundler                   Skips generating a bundle when publishing python function apps with build-native-deps. 
                                      Warning: Argument --no-bundler is deprecated and a no-op. Python function apps are not bundled anymore.
      --additional-packages <list>   List of packages to install when building native dependencies. 
                                      For example: "python3-dev libevent-dev"
      --squashfs                     (No description provided)

Arguments:
  <folder-name>                      Name of the folder (if the first argument doesn't start with "-")

Note: Replace [command] with the actual command name.

Falven avatar Sep 10 '23 20:09 Falven

@ahmelsayed we should document func pack as it provides an out-of-band way to create one-off remote deployment package to enable run from package URI scenarios and during testing. However, func pack is currently blocked for C# in-process apps (see https://github.com/Azure/azure-functions-core-tools/issues/3623). cc. @mattchenderson

ggailey777 avatar Mar 14 '24 00:03 ggailey777

Discovered func pack via a reddit thread. Extremely useful to create the deployment zip and host it somewhere like GitHub releases for functions to fetch and deploy such as for Flex Consumption in a bicep template.

JustinGrote avatar Aug 16 '24 01:08 JustinGrote

@ahmelsayed we should document func pack as it provides an out-of-band way to create one-off remote deployment package to enable run from package URI scenarios and during testing. However, func pack is currently blocked for C# in-process apps (see #3623). cc. @mattchenderson

Is there any documentation on the func pack method? Every time I invoke it I can never see any docs.

HaroonKhan-CVS-CSE avatar Mar 14 '25 14:03 HaroonKhan-CVS-CSE

@HaroonKhan-CVS-CSE the action code is here: https://github.com/Azure/azure-functions-core-tools/blob/main/src/Azure.Functions.Cli/Actions/LocalActions/PackAction.cs. The help text is disabled until the action is fully supported, which it currently isn't.

ggailey777 avatar Mar 16 '25 03:03 ggailey777

func pack will be available on the help menu in the next release! (v4.3.0)

aishwaryabh avatar Sep 16 '25 22:09 aishwaryabh