none
Running functions at cli outputs - Error calling the functions host: Unauthorized RRS feed

  • Question

  • I have an annoying issue in that when I run a function from the command line using "func run <func name>" the function host starts up and will serve requests but the command window where I ran the command from always displays "Error calling the functions host: Unauthorized" as soon as the function runtime is running.

    I have this with V1 installed via npm using the azure-cli package and I have it with V2 installed using pip, the error may be occuring in Visual Studio (running V1) but I haven't seen it there.

    I tried using different command prompts (cmd, cmd as Admin, ConEmu, ConEmu as Admin, Cmdr, Cmdr as Admin) and all produce the same behaviour.

    I found this StackOverflow post by David Ebbo which noted this behaviour as an issue which was supposed to be fixed in this PR.

    Whilst this isn't actively stopping me from developing it is a concern as something is obviously generating an error and I don't want to run into a brick wall where I can no longer develop due to this

    Tuesday, March 13, 2018 8:28 AM

All replies

  • I'm having problems reproducing this. Do you have repro steps?

    Here's what I tried:

    1. Download latest functions-core-tools from here:
    https://github.com/Azure/azure-functions-core-tools/releases/tag/1.0.9

    2. Unzip and use those tools to do the following:

    3. func init

    4. func new -> Pick C# -> HTTP

    5. func host start

    I get the following output

    λ ..\core-tools-1.0.9\func.exe host start
    
                      %%%%%%
                     %%%%%%
                @   %%%%%%    @
              @@   %%%%%%      @@
           @@@    %%%%%%%%%%%    @@@
         @@      %%%%%%%%%%        @@
           @@         %%%%       @@
             @@      %%%       @@
               @@    %%      @@
                    %%
                    %
    
    Skipping 'AzureWebJobsStorage' from local settings as it's already defined in current environment variables.
    Warning: 'connection' property in 'D:\code\temp\clitest\HttpGET-CRUD-CSharp\function.json' is empty.
    Listening on http://localhost:7071/
    Hit CTRL-C to exit...
    [3/13/2018 4:29:48 PM] Reading host configuration file 'D:\code\temp\clitest\host.json'
    [3/13/2018 4:29:48 PM] Host configuration file read:
    [3/13/2018 4:29:48 PM] {}
    [3/13/2018 4:29:48 PM] Starting Host (HostId=pbatumhost-812539253, Version=1.0.11535.0, ProcessId=12124, AppDomainId=1, Debug=False, ConsecutiveErrors=0, StartupCount=1, FunctionsExtensionVersion=)
    [3/13/2018 4:29:48 PM] Loaded custom extension 'BotFrameworkConfiguration'
    [3/13/2018 4:29:48 PM] Loaded custom extension 'SendGridConfiguration'
    [3/13/2018 4:29:48 PM] Loaded custom extension 'EventGridExtensionConfig'
    [3/13/2018 4:29:49 PM] Executing HTTP request: {
    [3/13/2018 4:29:49 PM]   "requestId": null,
    [3/13/2018 4:29:49 PM]   "method": "GET",
    [3/13/2018 4:29:49 PM]   "uri": "/"
    [3/13/2018 4:29:49 PM] }
    [3/13/2018 4:29:49 PM] Host lock lease acquired by instance ID '00000000000000000000000087B9EB90'.
    [3/13/2018 4:29:53 PM] Generating 1 job function(s)
    [3/13/2018 4:29:53 PM] Found the following functions:
    [3/13/2018 4:29:53 PM] Host.Functions.HttpGET-CRUD-CSharp
    [3/13/2018 4:29:53 PM]
    [3/13/2018 4:29:53 PM] ServicePointManager.DefaultConnectionLimit is set to the default value of 2. This can limit the connection throughput to services like Azure Storage. For more information, see https://aka.ms/webjobs-connections.
    [3/13/2018 4:29:53 PM] Executed HTTP request: {
    [3/13/2018 4:29:53 PM]   "requestId": "a488b278-3388-4bd6-a8cf-39cc5d36a4de",
    [3/13/2018 4:29:53 PM]   "method": "GET",
    [3/13/2018 4:29:53 PM]   "uri": "/",
    [3/13/2018 4:29:53 PM]   "authorizationLevel": "Anonymous"
    [3/13/2018 4:29:53 PM] }
    [3/13/2018 4:29:53 PM] Response details: {
    [3/13/2018 4:29:53 PM]   "requestId": "a488b278-3388-4bd6-a8cf-39cc5d36a4de",
    [3/13/2018 4:29:53 PM]   "status": "OK"
    [3/13/2018 4:29:53 PM] }
    [3/13/2018 4:29:53 PM] Job host started
    
    Http Functions:
    
            HttpGET-CRUD-CSharp: http://localhost:7071/api/HttpGET-CRUD-CSharp
    
    Debugger listening on [::]:5858

    Edit:

    I also checked creating a HTTP POST function and running that using func run and don't see anything unusual. Here's the extra output from doing func run:

    [3/13/2018 4:35:52 PM] Host Status: {
    [3/13/2018 4:35:52 PM]   "id": "pbatumhost-812539253",
    [3/13/2018 4:35:52 PM]   "state": "Running",
    [3/13/2018 4:35:52 PM]   "version": "1.0.11535.0"
    [3/13/2018 4:35:52 PM] }
    [3/13/2018 4:35:52 PM] Executed HTTP request: {
    [3/13/2018 4:35:52 PM]   "requestId": "da563f76-086f-45cf-be79-6c4a907578cd",
    [3/13/2018 4:35:52 PM]   "method": "GET",
    [3/13/2018 4:35:52 PM]   "uri": "/admin/host/status",
    [3/13/2018 4:35:52 PM]   "authorizationLevel": "Anonymous"
    [3/13/2018 4:35:52 PM] }
    [3/13/2018 4:35:52 PM] Response details: {
    [3/13/2018 4:35:52 PM]   "requestId": "da563f76-086f-45cf-be79-6c4a907578cd",
    [3/13/2018 4:35:52 PM]   "status": "OK"
    [3/13/2018 4:35:52 PM] }
    [3/13/2018 4:35:52 PM] Executing HTTP request: {
    [3/13/2018 4:35:52 PM]   "requestId": null,
    [3/13/2018 4:35:52 PM]   "method": "GET",
    [3/13/2018 4:35:52 PM]   "uri": "/admin/functions/HttpPOST-CRUD-CSharp/status"
    [3/13/2018 4:35:52 PM] }
    [3/13/2018 4:35:53 PM] Executed HTTP request: {
    [3/13/2018 4:35:53 PM]   "requestId": "d5be50f9-5143-4e31-88ff-db28908b622e",
    [3/13/2018 4:35:53 PM]   "method": "GET",
    [3/13/2018 4:35:53 PM]   "uri": "/admin/functions/HttpPOST-CRUD-CSharp/status",
    [3/13/2018 4:35:53 PM]   "authorizationLevel": "Anonymous"
    [3/13/2018 4:35:53 PM] }
    [3/13/2018 4:35:53 PM] Response details: {
    [3/13/2018 4:35:53 PM]   "requestId": "d5be50f9-5143-4e31-88ff-db28908b622e",
    [3/13/2018 4:35:53 PM]   "status": "OK"
    [3/13/2018 4:35:53 PM] }
    [3/13/2018 4:35:53 PM] Executing HTTP request: {
    [3/13/2018 4:35:53 PM]   "requestId": null,
    [3/13/2018 4:35:53 PM]   "method": "POST",
    [3/13/2018 4:35:53 PM]   "uri": "/api/HttpPOST-CRUD-CSharp"
    [3/13/2018 4:35:53 PM] }
    [3/13/2018 4:35:53 PM] Function started (Id=e8d83412-acf3-41b8-b4df-47f38fb7ce34)
    [3/13/2018 4:35:53 PM] Executing 'Functions.HttpPOST-CRUD-CSharp' (Reason='This function was programmatically called via the host APIs.', Id=e8d83412-acf3-41b8-b4df-47f38fb7ce34)
    [3/13/2018 4:35:53 PM] Function completed (Success, Id=e8d83412-acf3-41b8-b4df-47f38fb7ce34, Duration=159ms)
    [3/13/2018 4:35:53 PM] Executed 'Functions.HttpPOST-CRUD-CSharp' (Succeeded, Id=e8d83412-acf3-41b8-b4df-47f38fb7ce34)
    [3/13/2018 4:35:53 PM] Executed HTTP request: {
    [3/13/2018 4:35:53 PM]   "requestId": "c37465b7-6231-4917-ae31-fbb84f446a5f",
    [3/13/2018 4:35:53 PM]   "method": "POST",
    [3/13/2018 4:35:53 PM]   "uri": "/api/HttpPOST-CRUD-CSharp",
    [3/13/2018 4:35:53 PM]   "authorizationLevel": "Anonymous"
    [3/13/2018 4:35:53 PM] }
    [3/13/2018 4:35:53 PM] Response details: {
    [3/13/2018 4:35:53 PM]   "requestId": "c37465b7-6231-4917-ae31-fbb84f446a5f",
    [3/13/2018 4:35:53 PM]   "status": "BadRequest"
    [3/13/2018 4:35:53 PM] }
    Debugger listening on [::]:5858


    Tuesday, March 13, 2018 4:33 PM
  • Hi Paul,

    The error isn't in the command window that outputs the functions info but the command that spawned the func, I've attached a screenshot of the command windows to provide some additional detail

    The TestGet function in this case is the standard HttpGet function created from the template using

    func new -> JavaScript -> HttpGet

    • Edited by Nathan_ Tuesday, March 13, 2018 5:48 PM change formatting and added the template command
    Tuesday, March 13, 2018 5:43 PM
  • I'm still not able to get the same behavior, but I'll note that the run command indicates it only works for POST methods:


    Tuesday, March 13, 2018 11:49 PM
  • Turns out I didn't have the V2 runtime installed at all, what I installed via pip was the standard azure-cli.

    I removed V1 runtime completely and installed V2 via npm and now I have a different experience in that I use func start and it runs the function runtime in the same cli without any errors.

    Monday, March 19, 2018 9:27 PM