Tom
Tom

Reputation: 8691

Azure Function URL missing Function key

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));
        }
    }

Upvotes: 1

Views: 3627

Answers (1)

Tom W
Tom W

Reputation: 5422

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.

Upvotes: 2

Related Questions