Forum Discussion

Blarfnort's avatar
Blarfnort
Copper Contributor
Feb 26, 2025

Accessing a deployed NodeJS app?

I'm a complete noob to Azure.  I have managed to deploy a NodeJS all to a Function App (container?).  I can go into Deployment > Advanced > Kudu and then to Debug Console > CLI, and it will show a directory listing.  In my case, I see:

 

A/SP.NET

/data

/LogFiles

/ShutdownSential

/site

.gitconfig

gitsafedirectory.marker

 

So I go into /site and then into /wwwroot, and I see my files:

 

/node_modules

host.json

index.js

 

The default URL for this is (I obfuscated the sensitive bits) is blahblah-func-70.azurewebsites.net.  If I go to this URL I get a pretty page saying my function is running.  What I need to get to is the index.js file.  What URL do I use to do that?  If I append /index.js to that URL, I get a 404.

 

Thanks!

 

  • Try this:

     

    Create an HTTP Trigger: In your index.js file, you need to define an HTTP-triggered function:

    module.exports = async function (context, req) {
        context.log('HTTP trigger function processed a request.');
    
        const name = (req.query.name || (req.body && req.body.name));
        const responseMessage = name
            ? `Hello, ${name}. This HTTP triggered function executed successfully.`
            : "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response.";
    
        context.res = {
            // status: 200, /* Defaults to 200 */
            body: responseMessage
        };
    };
    

    Configure function.json: Ensure you have a function.json file in the same directory as your index.js file:

    {
        "bindings": [
            {
                "authLevel": "function",
                "type": "httpTrigger",
                "direction": "in",
                "name": "req",
                "methods": ["get", "post"]
            },
            {
                "type": "http",
                "direction": "out",
                "name": "res"
            }
        ]
    }
    
    • Deploy Your Function: Make sure your function is deployed to Azure. You can do this using the Azure CLI, Visual Studio Code, or directly from the Azure portal.
    • Access Your Function: Once deployed, you can access your function using the URL format: https://<your-function-app-name>.azurewebsites.net/api/<function-name>. For example, if your function app name is blahblah-func-70 and your function name is HttpTrigger1, the URL would be https://blahblah-func-70.azurewebsites.net/api/HttpTrigger1.
    • Blarfnort's avatar
      Blarfnort
      Copper Contributor

      Thank you.  Wow, this is complicated.

       

      So based on what you wrote, I created function.json and put your code in it and uploaded it to the directory. Next, I added the function for the trigger in my index.js and uploaded that as well. Then I went to the URL using the pattern you suggested, and I get a 404.

       

      Do I have to define this trigger somewhere in Azure?  Somebody else created the function app resource and I don't see how or where Node was specified.  

       

      Thank you for your help...

Resources