简体   繁体   中英

How to deploy and run an asp.net mvc 6 web api project in azure using git

I'm trying to deploy a simple mvc 6 web api project in azure and am having trouble.

I've crated the basic getting started example api http://docs.asp.net/projects/mvc/en/latest/getting-started/first-web-api.html and pointed my azure web application resource to my git repository.

I see that the git push triggers a deployment, the app is running, but I get a 404 response when I make a request.

The event viewer shows an event Engine state is changed from Available to Stopped.

FREB logs shows OUTPUT_CACHE_LOOKUP_END Result="NOT_FOUND"

How can I diagnose and what is the correct way to deploy mvc 6 apps on azure using git?

I forked your repo and deployed it to a Standard Web App (not Free since RC1 has a size problem and can't be deployed to Free Web Apps)on: http://myparkmvc6demost.azurewebsites.net/

Since your project is a WebApi, the correct way of accessing it is: http://myparkmvc6demost.azurewebsites.net/api/todo

This is defined in your TodoController :

namespace ttg_api.Controllers
{  
    [Route("api/[controller]")]
    public class TodoController : Controller
    {
        [FromServices]
        public ITodoRepository TodoItems { get; set; }

        // GET: api/todo
        [HttpGet]
        public IEnumerable<TodoItem> GetAll()
        {
            return TodoItems.GetAll();
        }

//more code....
}

You won't find anything if your browse the root of the site, this is not an Mvc "Website" by the normal understanding, it's using MVC6 to create a WebApi because that's the way in ASPNET5.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM