2

Hi, I am trying to debug and develop locally a simple JavaScript timerTrigger function azure application but I am having trouble. I am trying to follow along this tutorial: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local

Investigative information

Please provide the following:

  • Timestamp:
  • Function App name: testcenter123
  • Function name(s) (as appropriate): noderepo
  • Invocation ID:
  • Region:
Repro steps

I have the application handled via a Git repo so it's on my local machine as well.

Provide the steps required to reproduce the problem:

  1. Go to root level of function app and run (via powershell): func host start --debug vscode

    λ func host start --debug vscode
    
                  %%%%%%
                 %%%%%%
            @   %%%%%%    @
          @@   %%%%%%      @@
       @@@    %%%%%%%%%%%    @@@
     @@      %%%%%%%%%%        @@
       @@         %%%%       @@
         @@      %%%       @@
           @@    %%      @@
                %%
                %
    
    [10/16/2017 6:54:48 PM] Host has been specialized
    Listening on http://localhost:7071/
    Hit CTRL-C to exit...
    [10/16/2017 6:54:48 PM] Reading host configuration file 'C:\Users\xxxxxxxx\code\test-repos\NodeRepo1\host.json'
    [10/16/2017 6:54:48 PM] Host configuration file read:
    [10/16/2017 6:54:48 PM] { }
    [10/16/2017 6:54:48 PM] Loaded custom extension 'BotFrameworkConfiguration'
    [10/16/2017 6:54:48 PM] Loaded custom extension 'SendGridConfiguration'
    [10/16/2017 6:54:48 PM] Loaded custom extension 'EventGridExtensionConfig'
    [10/16/2017 6:54:48 PM] Generating 0 job function(s)
    [10/16/2017 6:54:48 PM] Starting Host (HostId=laptop2062-1189224982, Version=1.0.11232.0, ProcessId=8180, Debug=False, Attempt=0)
    [10/16/2017 6:54:48 PM] No job functions found. Try making your job classes and methods public. If you're using binding extensions (e.g. ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. config.UseServiceBus(), config.UseTimers(), etc.).
    [10/16/2017 6:54:48 PM] Job host started
    [10/16/2017 6:54:48 PM] Executing HTTP request: {
    [10/16/2017 6:54:48 PM]   "requestId": "b2d45bf0-1947-4ad7-a9cd-cdfa469d04d2",
    [10/16/2017 6:54:48 PM]   "method": "GET",
    [10/16/2017 6:54:48 PM]   "uri": "/"
    [10/16/2017 6:54:48 PM] }
    [10/16/2017 6:54:48 PM] Executed HTTP request: {
    [10/16/2017 6:54:48 PM]   "requestId": "b2d45bf0-1947-4ad7-a9cd-cdfa469d04d2",
    [10/16/2017 6:54:48 PM]   "method": "GET",
    [10/16/2017 6:54:48 PM]   "uri": "/",
    [10/16/2017 6:54:48 PM]   "authorizationLevel": "Anonymous"
    [10/16/2017 6:54:48 PM] }
    [10/16/2017 6:54:48 PM] Response details: {
    [10/16/2017 6:54:48 PM]   "requestId": "b2d45bf0-1947-4ad7-a9cd-cdfa469d04d2",
    [10/16/2017 6:54:48 PM]   "status": "OK"
    [10/16/2017 6:54:48 PM] }
    launch.json for VSCode configured.
    Debugger listening on [::]:5858
    [10/16/2017 6:54:51 PM] Executing HTTP request: {
    [10/16/2017 6:54:51 PM]   "requestId": "9fe12a9e-446a-4c8e-90db-d0004ac42e31",
    [10/16/2017 6:54:51 PM]   "method": "GET",
    [10/16/2017 6:54:51 PM]   "uri": "/admin/functions/noderepo"
    [10/16/2017 6:54:51 PM] }
    [10/16/2017 6:54:51 PM] Executed HTTP request: {
    [10/16/2017 6:54:51 PM]   "requestId": "9fe12a9e-446a-4c8e-90db-d0004ac42e31",
    [10/16/2017 6:54:51 PM]   "method": "GET",
    [10/16/2017 6:54:51 PM]   "uri": "/admin/functions/noderepo",
    [10/16/2017 6:54:51 PM]   "authorizationLevel": "Anonymous"
    [10/16/2017 6:54:51 PM] }
    [10/16/2017 6:54:51 PM] Response details: {
    [10/16/2017 6:54:51 PM]   "requestId": "9fe12a9e-446a-4c8e-90db-d0004ac42e31",
    [10/16/2017 6:54:51 PM]   "status": "MethodNotAllowed"
    [10/16/2017 6:54:51 PM] }
    
  2. Visit in browser http://localhost:7071/admin/functions/noderepo

Expected behavior

Upon vising my timer trigger, I get:

<Error>
<Message>
The requested resource does not support http method 'GET'.
</Message>
</Error>

I tried substituting noderepo with timerTrigger and myTrigger in the URL and still same thing. How do I debug this?

Actual behavior

Execute the JavaScript function method and break on the VS Code

Other information

My index.js is this:

module.exports = function (context, myTimer) {
    var timeStamp = new Date().toISOString();

    config.UseTimers();

    if(myTimer.isPastDue)
    {
        context.log('JavaScript is running late!');
    }
    context.log('JavaScript timer trigger function ran!', timeStamp);

    context.done();
};

Very simple....

2
  • Where did you copy and paste this from? Commented Oct 16, 2017 at 19:13
  • @War10ck I posted this from GitHub's issue page where I also posted this: github.com/Azure/azure-webjobs-sdk-script/issues/2037 Commented Oct 16, 2017 at 19:14

3 Answers 3

1

It looks like you do not have function folder near host.json. Can you please verify you have following folder: C:\Users\xxxxxx\code\test-repos\NodeRepo1\{yourFunctionN‌​ame}? If not create it using:

func new -l Javascript -t TimerTrigger -name myTimer

After that you should see: You should see in startup logs something like:

[10/16/2017 11:05:15 PM] Found the following functions: 
[10/16/2017 11:05:15 PM] Host.Functions.myTimer
Sign up to request clarification or add additional context in comments.

1 Comment

Hi, could you do me a favor and remove my name after \Users?, please and thank you.. Anyway, I have my noderepo1 and I want that ot be my function app. Anyway, I think it's best I just use the CLI to publish. Becuase I DO have a host.json which has {}. Question though... can you tell me what you used? Because I tried your func new and then I tried func host start and I still got the same error.
1

Have you tried running the new version of the Azure tools cli?

npm install azure-functions-core-tools@core

The new version of the cli is build on .NET core and it is x-platform. The architecture doesn't rely on Edge.js anymore instead it offloads processing to a node worker. The cli worker always starts with --inspect which should allow you to debug easily with VSCode or chrome, you just need to make sure your launch.json is properly configured and matches the address and port.

{
     "type": "node",
     "request": "attach",
     "name": "Attach to Remote",
     "address": "localhost",
     "port": 9229, // Or 5858 
     "sourceMaps": true,
     "localRoot": "${workspaceRoot}"
}

Also this should allow you to upgrade to node > 6.5.0 if you need, only caveat I believe you'll need to change the runtime in your Azure function to enable it.

2 Comments

Oh, I see! Use the cli tool instead of the UI on Azure? So, if I were to set up via CLI and then do a pubish, I would have a new function azure app with like timer triggers and powershell and whatnot?
That's right you can use the cli tool to publish your functions from your machine to azure functions using func azure functionapp publish functionName
1

Here is the answer a little more clearly laid out. I did not find Microsoft's Article very clear either and it was Alexey Rodionov's answer set set me on the correct route.

Assuming that you want to reference the endpoint as http://localhost:7071/api/MyFunction

The directory structure should look like this:

enter image description here

  • MyFunction must be the name of the directory
  • The files function.json & index.js must be in that directory.

The following two files are at the root of your solution.

  • host.json
  • local.settings.json

What I found missing from Microsoft's article was the fact that you had to change directory between the steps.

func init Sample
cd Sample
func new --language JavaScript --template "Http Trigger" --name MyFunction

` Note that the way you specify "Http Trigger" is also not correct in the article.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.