Unable to Save Code in Azure Function and Upload Model Files via Kudu Console

Abdullah Alhomedna 0 Reputation points
2024-09-30T17:58:46.8+00:00

I am working with a JavaScript Azure Function App to deploy machine learning models for mood and emotion predictions. However, I have encountered two main issues:

Unable to Save Code in the Azure Function Editor: When trying to update and save the function code, I repeatedly receive an error message at the top of the Azure Function Editor, preventing me from saving the changes. The editor does not allow saving any modifications, even though I’ve verified the function app settings.

Unable to Upload Model Files Using Kudu Console: I need to upload two .h5 model files for the Azure Function, but I am unable to upload them using the Kudu console. Although I successfully accessed Kudu, I could not find an option to upload the files via the file explorer or console. I attempted to use both Kudu and the Azure portal for file uploads, but the process did not work as expected.

Steps Taken So Far:

  • Accessed Kudu and navigated to the wwwroot directory.
  • Attempted to upload the models using Kudu but could not find the "Upload" button in the interface.
  • Tried saving function code updates via the Azure Function App Editor but encountered an error message.

Request:

  • Assistance with enabling the "Save" functionality in the Azure Function App Editor so I can successfully save and run my function code.
  • Guidance on how to upload the model files correctly through Kudu or an alternative method (such as FTP or Zip Deployment) since the "Upload" button is not visible in Kudu.

Thank you.I am working with a JavaScript Azure Function App to deploy machine learning models for mood and emotion predictions. However, I have encountered two main issues:

Unable to Save Code in the Azure Function Editor: When trying to update and save the function code, I repeatedly receive an error message at the top of the Azure Function Editor, preventing me from saving the changes. The editor does not allow saving any modifications, even though I’ve verified the function app settings.

Unable to Upload Model Files Using Kudu Console: I need to upload two .h5 model files for the Azure Function, but I am unable to upload them using the Kudu console. Although I successfully accessed Kudu, I could not find an option to upload the files via the file explorer or console. I attempted to use both Kudu and the Azure portal for file uploads, but the process did not work as expected.

Steps Taken So Far:

  • Accessed Kudu and navigated to the wwwroot directory.
  • Attempted to upload the models using Kudu but could not find the "Upload" button in the interface.
  • Tried saving function code updates via the Azure Function App Editor but encountered an error message.

Request:

  • Assistance with enabling the "Save" functionality in the Azure Function App Editor so I can successfully save and run my function code.
  • Guidance on how to upload the model files correctly through Kudu or an alternative method (such as FTP or Zip Deployment) since the "Upload" button is not visible in Kudu.

Thank you.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,085 questions
Azure Startups
Azure Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Startups: Companies that are in their initial stages of business and typically developing a business model and seeking financing.
378 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 15,886 Reputation points Microsoft Employee
    2024-10-01T18:11:45.9766667+00:00

    Hi @Abdullah Alhomedna I have tested making edits to my JavaScript function app through Azure portal and could upload a file using Kudu console without any issues.

    I have created the app using Node 20 LTS version and windows OS. Here is my environment variables configuration of my Function app

    User's image

    If you see an Environment variable with name WEBSITE_RUN_FROM_PACKAGE, delete that setting and restart the app to see if that helps.

    Here are my configuration settings

    User's image

    Please let us know the error message you are encountering to help us better understand the issue.


    Alternatively, you can use other development tools such as VS Code or Visual Studio to develop and deploy the changes to the code and upload new files to the Function App. If you are using VS Code, you can use the Azure Functions extension v1.10.4 extension to create a function app locally and deploy the code to an existing function app or a new app. Please refer the QuickStart guide for detailed steps on the set up.

    Here is a sample project directory where I have added a few files to the function app through my VS Code under assets directory of my function app project.

    User's image

    Once deployed, the files would be available under base directory "C:\\home\\site\\wwwroot\\src\\" of the function app if it is hosted on Windows OS. I can access the file as follows through my code

            const baseFolderPath = "C:\\home\\site\\wwwroot\\src\\";
            const fileRelativePath = "assets\\apim-liquid-json-parse-policy-sample (1).txt";
            const filePath = baseFolderPath + fileRelativePath; 
            fs.readFile(filePath, 'utf8', function(err, data) {
                if (err) {
                    return context.log(err);
                }
                context.log(data);
            });
    
    

    Hope this helps!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.