Azure function is not deployed from VS - No HTTP triggers found

Benjamin Koubik 35 Reputation points
2023-10-24T12:50:54.0766667+00:00

I created an Azure POST function that works wonderfully locally. When I deploy the whole thing using VS, I see 'No HTTP triggers found.' in the output. The function does not appear in my dashboard

User's image

User's image

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,353 questions
{count} votes

Accepted answer
  1. navba-MSFT 17,395 Reputation points Microsoft Employee
    2023-10-26T12:01:17.7166667+00:00

    @Benjamin Koubik Thanks for your reply. Lets take a step back and do this in the same way I did at my end from scratch. Hopefully that might help.

    We will do it using a new function app project right from scratch. Follow the below steps one by one:

    • Create a new empty folder and open this folder using VS code.
    • Then open the New terminal in VS code and navigate to this folder.
    • Run the func init command, as follows, to create a functions project in a folder named LocalFunctionProj:

    func init LocalFunctionProj --model V4

    You're then prompted to choose a worker runtime and a language - choose Node for the first and JavaScript for the second.

    • Navigate into the project folder:

    cd LocalFunctionProj

    • Add a function to your project by using the following command:

    func new

    • Choose the template for "HTTP trigger". You can keep the default name (httpTrigger) or give it a new name (HttpExample).
    • Replace the existing content with below in your local.settings.json.
    {
    
      "IsEncrypted": false,
    
      "Values": {
    
        "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=aidocumentanalysing;AccountKey=8DOb+NvimZg1b9GOCi1IeUTT7ZSq8fAJkqEXbqx0GOtfhSoAl4LNVvkz3BDIhcsvKu81xurMUqku+AStPfVeLQ==;EndpointSuffix=core.windows.net",
    
        "FUNCTIONS_WORKER_RUNTIME": "node",
    
        "AzureWebJobsFeatureFlags": "EnableWorkerIndexing",
    
        "FORM_RECOGNIZER_API_KEY": "22651ab54aad4a289c6988b743fcd1e0",
    
        "FORM_RECOGNIZER_ENDPOINT": "https://eastus.api.cognitive.microsoft.com/",
    
        "FORM_RECOGNIZER_CUSTOM_MODEL_ID": "workingplan-last-test-for-today"
    
      }
    
    }
    
    
    
    • You can find the function you added in the src/functions directory.
    • Open the JS file and Add the below code:
    const { DocumentAnalysisClient, AzureKeyCredential } = require("@azure/ai-form-recognizer");
    const { app } = require('@azure/functions');
    
    app.http('httpTrigger', {
        methods: ['GET', 'POST'],
        authLevel: 'anonymous',
        handler: async (request, context) => {
            if (request.method === "GET") {
                return { body: "Hello, world!" };
            }
    
            const { url } = await request.json();
    
            const client = new DocumentAnalysisClient(
                process.env.FORM_RECOGNIZER_ENDPOINT,
                new AzureKeyCredential(process.env.FORM_RECOGNIZER_API_KEY)
            );
          
            const poller = await client.beginAnalyzeDocument(
                process.env.FORM_RECOGNIZER_CUSTOM_MODEL_ID,
                url,
                {
                  onProgress: ({ status }) => {
                    console.log(`status: ${status}`);
                  },
                }
            );
    
            const {
                documents: [document],
            } = await poller.pollUntilDone();
    
            if (!document) {
                throw new Error("Expected at least one document in the result.");
            }
            return { body: JSON.stringify(document.fields) };
        }
    });
    
    • In your VS code terminal run the below commands one by one:
      • npm install @azure/ai-form-recognizer
        • npm install @azure/functions
    • Run your function by starting the local Azure Functions runtime host from the LocalFunctionProj folder.

    func start

    • Test and confirm it works locally.
    • Then you can deploy to your Azure Function using func cli as: func azure functionapp publish FUNC_NAME
    • Then check if you see the http_trigger getting deployed. Also test from portal.
    • You should be also able to send the GET verb to this function app and it should show HELLO WORLD message.

    ** Please do not forget to "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful