1

I have deployed .Net core function app in Azure. Have successfully created a Build and release pipeline. When I go the the specific function in Azure and click the button Get Function URL, I dont see function key appended to the url

All i see is the following error

https://srlcustomermanagerapp.azurewebsites.net/api/customers-details

When I try to run this url , I get 500 internal error. I have run the function app locally and it runs perfectly fine.

Am I missing some configuration in the Azure portal as when I click the Get Url button I should be getting an URL with the function key to it

I tried running the function from code + Test shown below as well as using postman and get 500 error

Screenshot

enter image description here

Get Function URL

enter image description here

Function

 public  class GetCustomersOrders
    {
        private readonly ICustomerOrdersRepository _repo;
        private readonly IMapper _mapper;
        private readonly TelemetryClient _telemetryClient;


        public GetCustomersOrders(ICustomerOrdersRepository repo, IMapper mapper, TelemetryConfiguration configuration)
        {
            _repo = repo;
            _mapper = mapper;
            _telemetryClient = new TelemetryClient(configuration);
        }

        [FunctionName("GetCustomersOrders")]
        public async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", Route = "customer-orders")] HttpRequest req,
            ILogger log)
        {
            this._telemetryClient.TrackTrace("C# HTTP trigger function processed a request.");
            var customersOrders = _repo.GetCustomerOrders();
            return new OkObjectResult(_mapper.Map<List<CustomerOrdersViewModel>>(customersOrders));
        }
    }

1 Answer 1

2

The configuration setting "authLevel": "anonymous" may be to blame. As per the documentation:

Functions lets you use keys to make it harder to access your HTTP function endpoints during development. Unless the HTTP access level on an HTTP triggered function is set to anonymous, requests must include an API access key in the request.

So my guess is that the function isn't expecting a function key because of this setting, and the fact you're getting a 500 back is a red herring and nothing to do with a missing function key.

Sign up to request clarification or add additional context in comments.

4 Comments

This is what my function contains public async Task<IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "customer-orders")] HttpRequest req, ILogger log)
Change the AuthorizationLevel on the trigger attribute to Function then, and that should enable function key authentication, but I'll bet this won't solve the 500 error. 500 implies your code is being hit, although this isn't a certaintly in some parts of Azure. If you don't already have Application Insights configured, that will provide some fairly detailed exception information to allow you to diagnose.
I did as you mentioned. Changing the AuthorizationLevel on the trigger attribute to Function. It did generate the key but made no difference. I added Application Insights telemetry code in my function but dont see that line getting run. I have update my post with the telemetry code. It isnt capturing anything apart from letting us know that telemetry is running. But dont see that in console while running the app via Code +Test section in Azure
I wasn't envisaging code-based telemetry but rather built-in app insights integration which is really just a config setting; I'm vague on the details of exactly how it does this but Functions provide some fairly rich telemetry natively without having to log in code.

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.