In this post, we will look at the error “Backend service URL is not defined” when making a request to an ASP.NET Web API through API Management.
I have a .NET Core Web Api with Swashbuckle / Swagger. The Web Api is published to an Azure App Service, and an Azure API Management has this API loaded.
We can run a test message using the APIM:
We get a 500 Internal Server Error:
To examine the response, click on Trace and Backend:
We see the message “Backend service URL is not defined”:
To resolve this, in APIM go to the App Service. Under Settings, in the Web Service URL field, enter the URL of the app service:
Now when you run this, you will get a 200 response back:
I AM SPENDING MORE TIME THESE DAYS CREATING YOUTUBE VIDEOS TO HELP PEOPLE LEARN THE MICROSOFT POWER PLATFORM.
IF YOU WOULD LIKE TO SEE HOW I BUILD APPS, OR FIND SOMETHING USEFUL READING MY BLOG, I WOULD REALLY APPRECIATE YOU SUBSCRIBING TO MY YOUTUBE CHANNEL.
THANK YOU, AND LET'S KEEP LEARNING TOGETHER.
CARL
thanks man, you saved my day 🙂
Glad it helped, thanks Harsha!
Thanks a lot 🙂
Thanks Carl. It helped me.
I have configured self hosted API Management and i unable to test the api through postman.
When i try to run the docker image as par the below command provided, my docker image is running properly but i am not able to consume the API.
docker run -d -p 80:8080 -p 443:8081 –name SelfGateway –env-file env.conf mcr.microsoft.com/azure-api-management/gateway:v2
After this command, i can see my self hosted gateway showing => 1 instance(s), last heartbeat at 10:09:45 PM
I am using localhost url to consume it.
The following error showing in Postman result pane =>
{
“statusCode”: 500,
“message”: “Internal server error”,
“activityId”: “ae2b1498-58cf-4c32-bd19-8236fe40b0f0”
}
The following logs showing in docker logs
[Info] 2022-12-8T04:42:36.857, isRequestSuccess: False, totalTime: 1, category: GatewayLogs, callerIpAddress: 172.17.0.1, timeGenerated: 12/08/2022 16:42:36, region: Pune, correlationId: 1720c6b0-31e4-4f4a-a3d3-7330273d6c0a, method: GET, url: http://localhost/local/WeatherForecast, responseCode: 500, responseSize: 191, cache: none, apiId: webapicore, operationId: GetWeatherForecast, clientProtocol: HTTP/1.1, apiRevision: 1, lastError: {
“elapsed”: 1,
“source”: “request-forwarder”,
“path”: “forward-request\\forward-request”,
“message”: “Backend service URL is not defined.”,
“section”: “backend”
}, errors: [
{
“elapsed”: 1,
“source”: “request-forwarder”,
“path”: “forward-request\\forward-request”,
“message”: “Backend service URL is not defined.”,
“section”: “backend”
}
], correlationId: 1720c6b0-31e4-4f4a-a3d3-7330273d6c0a