How to edit a read-only Azure Function python code

Viewed 275

I'm trying to add a fix to a previously-uploaded Azure Function, and can't seem to get anywhere.

Here's what I have done so far:

  • Trying to make changes through the in-browser editor, a banner at the top of the page pops up:
    This function has been edited through an external editor. Portal editing is disabled.
    Unsurprisingly, trying to type inside shows a Cannot edit in read-only editor message.

  • Next I installed the Azure Functions extension for Visual Studio Code, following this tutorial. Logged in, opened the solution, and still read-only, unable to be edited.

  • I then found this StackOverflow post showing how to download the Function app content, make your changes, and reupload. Unfortunately, the button to download the app content is greyed out in the portal, so I am unable to download the app files.

  • I tried changing the Function app config json by adding the FUNCTION_APP_EDIT_MODE tag and setting it to 'readwrite', to no success.

  • I have also tried directly uploading the fixed file via Azure portal, only to be met with an error saying that it only supports to uploads up to 5MB, despite the fixed file being only 13KB.

Does anyone have experience with this kind of issue? Any insight or pointers would be much appreciated.

Thanks

1 Answers

When you create the Python Function App in Azure Portal, the option "Download App Content" will be disabled: enter image description here After publishing the project from VS Code to Azure Function App: enter image description here

It happens because In-Portal editing is disabled for Azure Python Functions. Refer this GitHub Announcement for more info.


One of the workarounds to edit/update your Azure Python Functions code is:

  1. Create a new project and copy these files from the Azure Portal > Function App > App Files:
    • host.json file
    • requirements.txt file

enter image description here

  1. From the Azure Portal > Your Function App > Functions > Code+Test Menu of the Function >
    • init.py file
    • function.json file

enter image description here

Copy the codes of these files and paste them in your new Project.

Or you can edit the already published project in VS Code if you have it and publish the changes.


Another workaround is to set-up the Continuous Deployment using GitHub Source, so your project code is available in GitHub where you have edit option to modify the code from the GitHub and Push Changes to Azure.

enter image description here

Refer to Azure Functions Configure Continuous deployment for more information.


Related