Question

I am experiencing error 500 from the web-api MVC website deployed to Azure. WebApi controllers access Azure Table Storage and it works locally (local website works with my Azure Table).

Troubleshooting the problem I used "Linked Resources" page to link the website to the Storage but noticed the following: "The Customer Preview Release of the Windows Azure Management Portal does not support linking a storage account to a web site or a cloud service" Despite this message it shows status as "Linked".

Is it possible on this stage of Azure to access Table from the Web Sites?

Note: It is VS2010 and .net4

Code as requested:

    public static TableServiceContext GetContext()
    {
        CloudStorageAccount storageAccount = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=@cc0untKey==");

        CloudTableClient tableClient = storageAccount.CreateCloudTableClient();

        var context = tableClient.GetDataServiceContext();
        сontext.IgnoreResourceNotFoundException = true;
        return context;
    }

    public IEnumerable<Destination> GetAllDestinations()
    {
        try
        {
            return TableProvider.GetContext()
                       .CreateQuery<Destination>(Model.Consts.DestinationTableName);
        }
        catch (Exception e)
        {
            return new Destination[1]
            {
                new Destination()
                {
                    CountryName = e.Message
                }
            };
        }
    }
Was it helpful?

Solution

Project has been create in a wrong way. When you want to create a web site with web api you should choose Web -> MVC 4 and not Cloud -> MVC 4 Web role. By mistake I did second and then published the web site and not a web role.

OTHER TIPS

Yes. The storage service doesn't know or care where your code is running.

I don't know what "linking" does in the new portal, but I think it's just a management UI abstraction. I don't think it has any effect on the running code. (Maybe it sets up affinity groups?)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top