Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.32k stars 434 forks source link

Clarify 'func pack' #1135

Open matiaslahticgi opened 5 years ago

matiaslahticgi commented 5 years ago

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?

ahmedelnably commented 5 years ago

@asavaritayal to comment

asavaritayal commented 5 years ago

@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

matiaslahticgi commented 5 years ago

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.

ahmelsayed commented 5 years ago

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.

tbarlow12 commented 5 years ago

Any updates here?

tbarlow12 commented 5 years ago

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

TylerHaigh commented 5 years ago

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

poddubitskya commented 1 year ago

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.

Falven commented 1 year ago

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.
ggailey777 commented 7 months ago

@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

JustinGrote commented 2 months ago

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.