Deploying asp.net web api to azure app service - asp.net

Problem: after deploying my asp.net core web api to azure app service I can't get a response from the expected endpoint
Steps followed:
I have an api that works fine when serving from my local machine, developed using Visual Studio Code. (The code for that is here https://github.com/samrae7/blog-api FYI)
I followed the instructions in this video: https://www.youtube.com/watch?v=C8J_CRy2_XA to push the files up to Azure App services. Basically I used the VS Code azure app service extension to create a webapp on azure and push my files.
I can see my files have been pushed to Azure ( by logging in to the portal and looking) but when I navigate to the expected URL of my api, http://sams-blog-api.azurewebsites.net, I get 'site not found'. If I try to send a request to the expected endpoint (I append /api/resource as this is the path of the endpoints on my local machine) I get '404 not found'
So my question is what do I have to do to actually get my api up and running online after pushing the files to azure app service
Thanks

Your website is not accessible due to missing DNS entry. I check it using the mxtool
https://mxtoolbox.com/SuperTool.aspx?action=a%3asams-blog-api.azurewebsites.net&run=toolpage#
Please ensure that your url is correct.

The basic answer to this question was that I had not understood that you have to create a Database in azure for your deployed app to connect to, and you need to set the connection string as an env variable in azure so that it knows where to look, and you should also add code that automatically updates the database on launch.
This tutorial was what helped with that: https://learn.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-dotnetcore-sqldb
I then hit another issue where the deployed app was still returning a generic 500 server error. By enabling 'Diagnostic logs' via the azure portal, and downloading the logs, I saw this detailed error: The configuration section 'httpProtocol' cannot be read because it is missing a section declaration referring to a piece of config in my Web.config. I deleted it (I don't need it for now) and that fixed the issue

Related

Use fs.unlinkSync with full path to remove file in project, it works on local server, but it gives error(5xx) after deployed to azure web app

I have an app that builds with Vuejs and Nodejs server.
I created a folder called 'uploads' in the project to temporary store all of the files that was uploaded to the server.
When the uploaded action is ready, I have a restAPI to clean the file in folder 'uploads' with the given absolute path. I use fs.unlinkSync to remove the temp file in the rest api.
Everything works perfectly on local, but after I deploy to azure web app, whenever the restapi for removing a file is triggered, it gives me 502 bad gateway error.
I have checked a lot of information, still can not solve this problem. Wonder if anyone have experience with it?
Log from Azure Web App
Failed to forward request to application. Encountered a System.Threading.Tasks.TaskCanceledException exception after 300196.724ms with message: The operation was canceled.. Check application logs to verify the application is properly handling HTTP traffic.
Try to use fs.unlink(path, callback), then you can log more error details in callback function.
Suggestion
You also can use try..catch... to get more exception message. Get error details should be useful to you to solve the problem.
About Log from Azure Web App, I'm not sure how you use it, or use the default. The exception caught by the code may be more helpful to you.
If you use linux platform, you can use remote debugging.
Azure Remote Debugging for Node.js

Where can I see logs or details for error Azure "An error has occurred." for an API call on Azure?

I have an ASP.NET API and works great as local and using Postman.
Then I decided to publish to Azure since I tried on other free host SOMEE and never worked.
Principal API page on Azure works fine but when I tried to call a controller shows the error
{"Message":"An error has occurred."}
and I don't even know where to check more details about this error.
I tried the same on a Somee.com host and same thing happens
Azure portal offer to you some resources to investigate your issue
Log stream (in your App Service page, under Monitoring section), can give you some info of you api call.
Advanced Tools (in your App Service page, under Development Tools), can give you more information of your app settings, deployment info, wwwroot folder, etc...
It can be a deployment issue(related to the app service configuration, maybe you are using a docker container?) or a simple error in your connection string, so review your app service settings:
it's usually one of these(some) problems.
all the best

hosted dotnet core project webapi is not able to connect to database

Currently I am working in DotNetCore2 web api project from my local machine. It is pointing to remote server database(server : sql6001.site4now.net) .
I published the same api without making any changes. It seems that deployed api project is also working as I am able to get values from default controller[values] which do not have any database connection required.
But when i call other methods in controller having database connection required, i am getting nothing. I am not getting any exception, but all I am getting is empty value.
[
It seems that api project is not able to connect to database , could anybody help in this.

Web Service error - Status 404 not found

I have created a web service in Visual Studio 2015 (web api) that listens out for requests via a barcode scanner. The barcode scanner links to a database that provides information such as stock quantities etc, but this is just for background information. The web service is currently installed on my local machine and works perfectly, returning the correct values and posts data to a database.
I attempted to install the web service onto a server, copying over similar settings in IIS (only have basic knowledge using this), such as the bindings and ensuring the permissions were set up correctly. However when running the web service I recieved a "404 not found error and 401 unauthorized". After that, I installed Visual Studio 2015 onto the server to ensure it wasn't a build or publish error...same problem.
Below are some of the 'fixes' I have tried to help narrow down the potential problem.
Ensured the correct version of .Net, 4.0, is installed on the server.
IIS Manager - Authentication: Annoymous Authentication set to enabled.
IIS Manager - Directly browsing: set to enabled.
Set the correct permissions using 'Edit Permissions', granted full control to 'Everyone'
This is my first time creating a web service so up until now I have been using tutorials and making it up as I go along. I think it could be to do with the application pools set up? But because the solution works on my local machine and not the server has me extremely confused. Thanks in advance.

ASP.Net SignalR: http://127.0.0.1/signalr/hubs (404 Not found) when accessed from different application

I have created a simple chat application following the Getting Started With SignalR URL. When I run and test the program it is working wonderfully fine.
I tried to create a simple client out of this application with a simple HTML and required SignalR.JS package installed as instructed in the second part of Self Hosting SignalR the article where a html and set of JS files try to access the chat application hosted in IIS (one developed following the Getting Started URL.
I am getting the signalr/hubs 404 Not Found error when firebug is used to trace and is not working. Can someone please help me understand what change we need to do to get the chat server working from the JavaScript (and any other) client application.
My chat server is hosted in my IIS as srserver (virtual directory) and the client again is hosted in IIS as srclient (virtual directory) . It is not Cross domain but still not able to get this working.
I had similar problem , that i was missing in the auto generated hubs js (visual studio generates it automatically but when in production environment i had to place it there)
you can generate it using the following command, and than place in the production environment :
signalr ghp /path:[path to the .dll that contains your Hub class]
follow the full instrutinos here

Resources