Python Azure Functions Tips

Here are some tips of the things I’ve learned while creating them.

App Plan

If you already have an Windows ‘App Service Plan’ you’ll need a different one for running Python.

You can’t host Linux and Windows apps in the same resource group. If you have an existing resource group named AzureFunctionsQuickstart-rg with a Windows function app or web app, you must use a different resource group.

Python version

If you need to use ‘azure-identity’ you’ll need to use python 3.8 instead of the 3.9 otherwise you’ll get:

"ImportError: cannot import name 'cygrpc' from 'grpc._cython'"

This is quite confusing because it says the worker must be “Python 3.6, 3.7, and 3.8” on one side but on the other we get “3.7, 3.8 and 3.9”.

Azurite

The Azure Storage emulator that you may need to develop your Azure Functions. This was giving me some issues while trying to unit test my code. If you ever used this the usal connection string to access it is:

"UseDevelopmentStorage=true"

But with Python I was getting this error:

"Connection string missing required connection details."

This is a problem since 2020. The current workaround is to use the full connection string:

"DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"

You can read more about it and the workaround in the link below:

Pyenv-Win

This project is your friend. It will help you mantain different Python environments. You can even use chocolatey to install it. It’s great to be able to work on several projects with different needed versions.

Have fun!

 Share!