0
votes

I've created a new Mobile App in Azure and downloaded the starter project and published to Azure.

The default route / table works perfectly but whenever I try access any new tables I get "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable."

I've added the new tables to the dbContext and published to Azure. They show up on the list of tables when I view the DB through SQL Management studio so the tables are being created.

 public myAppContext() : base(connectionStringName)
    {
    }

    public DbSet<Member> Members { get; set; }
    public DbSet<ContactMethodType> ContactMethodTypes { get; set; }
    public DbSet<GenderType> GenderTypes { get; set; }
    public DbSet<Group> Groups { get; set; }
    public DbSet<MemberContribution> MemberContributions {get;set;}
    public DbSet<Invitation> Invitations { get; set; }

And I've added controllers for the new tables that match the original example controller but only that initial route seems to run.

using System.Linq;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Controllers;
using System.Web.Http.OData;
using Microsoft.Azure.Mobile.Server;
using myApp.DataObjects;
using myApp.Models;

namespace myApp.Controllers
{
    public class InvitationsController : TableController<Invitation>
    {
    protected override void Initialize(HttpControllerContext     controllerContext)
    {
        base.Initialize(controllerContext);
        myAppContext context = new myAppContext();
        DomainManager = new EntityDomainManager<Invitation>(context, Request);
    }

    // GET tables/Invitation
    public IQueryable<Invitation> GetAllInvitations()
    {
        return Query();
    }

    // GET tables/Invitation/48D68C86-6EA6-4C25-AA33-223FC9A27959
    public SingleResult<Invitation> GetInvitation(string id)
    {
        return Lookup(id);
    }

    // PATCH tables/Invitation/48D68C86-6EA6-4C25-AA33-223FC9A27959
    public Task<Invitation> PatchInvitation(string id, Delta<Invitation> patch)
    {
        return UpdateAsync(id, patch);
    }

    // POST tables/Invitation
    public async Task<IHttpActionResult> PostInvitation(Invitation item)
    {
        Invitation current = await InsertAsync(item);
        return CreatedAtRoute("Tables", new { id = current.Id }, current);
    }

    // DELETE tables/Invitation/48D68C86-6EA6-4C25-AA33-223FC9A27959
    public Task DeleteInvitation(string id)
    {
        return DeleteAsync(id);
    }
}
}
1

1 Answers

0
votes

What URL are you trying, according to the docs the root for your controller above should be https://<server>/tables/Invitations

https://azure.microsoft.com/en-gb/documentation/articles/app-service-mobile-dotnet-backend-how-to-use-server-sdk/#define-table-controller

Table controllers are initialized by using the AddTables extension method. This adds routes under /tables/ for all subclasses of TableController.