2

I'm using the command func azure functionapp publish to publish my python function app to Azure. As best I can tell, the command only packages up the source code and transfers it to Azure, then on a remote machine in Azure, the function app is "built" and deployed. The build phase includes the collection of dependencies from pypi. Is there a way to override where it looks for these dependencies? I'd like to point it to my ow pypi server, or alternatively, provide the wheels locally in my source tree and have it use those. I have a few questions/problems:

  1. Are my assumptions correct?
  2. Assuming they are, is this possible, and how?

I've tried a few things, read some docs, looked at the various --help options in the CLI tool, I've set up a pip.conf file that I've verified works for local pip usage, then on purpose "broken it" and tried to see if the publish would fail (it did not, so this leads me to believe it ignores pip.conf, or the build (and collection of dependencies happens on the remote end). I'm at a loss and any tips, pointers, or answers are appreciated!

Bryant
  • 3,011
  • 1
  • 18
  • 26

1 Answers1

3

You can add additional pip source to point to your own pypi server. Check https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python#remote-build-with-extra-index-url

Remote build with extra index URL: When your packages are available from an accessible custom package index, use a remote build. Before publishing, make sure to create an app setting named PIP_EXTRA_INDEX_URL. The value for this setting is the URL of your custom package index. Using this setting tells the remote build to run pip install using the --extra-index-url option. To learn more, see the Python pip install documentation.

You can also use basic authentication credentials with your extra package index URLs. To learn more, see Basic authentication credentials in Python documentation.

And regarding referring local packages, that is also possible. Check https://learn.microsoft.com/en-us/azure/azure-functions/functions-reference-python#install-local-packages

I hope both of your questions are answered now.

krishg
  • 5,935
  • 2
  • 12
  • 19
  • Thanks, I think this helps a lot. Another question - does this apply if using python function apps that are deployed in docker containers? – Bryant Aug 25 '20 at 13:05
  • 1
    (Sorry deleted previous comment about container as not correct). When you create a container, it is self-contained and you build it yourself. So, during that build itself, you have the opportunity to refer your private pypi source during pip install. PIP_EXTRA_INDEX_URL app setting is not applicable for containers. – krishg Aug 25 '20 at 13:29
  • Just to add to @krishg 's answer. An App setting is under function app/configuration. This means you need to have a function app first in order to update the app setting. To do so, deploy your function app (deployment will fail at first), then update the app settings, save and deploy gain – Abdelrahman Shoman Nov 02 '21 at 11:53