0

I developed a simple API using .Net core and it locally works as intended. After deployment only the WeatherForecast endpoint is working and the rest results in status 500. I have used code first with EF and enabled migrations during the publish process through VS code. Any suggestion?

Azure gives me these errors but I am not really familiar with Azure

image 1

my code

endpoint

EDIT: The endpoints are working now, but as I said in a comment below I changed my local db connection string (see my appsettings.json in git) by the one that azure gives me and everything is working correctly but, if you have alredy filled you db with many records probably that's not the entire solution

5
  • You need to share the relevant code in the question itself. Commented Jan 27, 2022 at 3:18
  • The endpoint you shared returns the JSON response successfully... where is the 500 error? Commented Jan 27, 2022 at 3:19
  • The enponit that I shared is the only working (WheatherForecast) the endpoints not working are azgeirr.azurewebsites.net/api/Products Commented Jan 27, 2022 at 3:26
  • This error normally occurs due to a “NullReferenceException” wherein you attempt to read a parameter value that hasn’t been defined yet or is set to null. Commented Jan 27, 2022 at 6:24
  • Please refer Troubleshooting 5xx Errors with Azure APIM services for more information. Commented Jan 27, 2022 at 7:12

1 Answer 1

0

Looking into your code, I see that you have added connection string of the localdb. Did you update this in configuration on app service?

I am pretty sure that your application is unable to connect to the database and hence the 500 : internal server error

Also you should add appsettings to .gitignore so that it is not pushed to a remote public repository.

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

3 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
I think thats my problem but as I said, I am not familiar with azure and since the beggining the part of the connection strings confuses me because in vs code i got this config but I am not sure if I did it correctly imgur.com/a/iTpvcLe
Well everything works now changing the connections string in appsettings.json file by the one that azure gives me, but doing this the azure db has no data (in this case don't care because I used to have only 5 records) so I think is not what I wanted at the beggining

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.