Azure error "Resource not found" - catch all error?

Microsoft Bug Report  ID: 533542
Title: Linq query against TableStorageRoleProvider results in InvalidOperation if role is not found

If you ended up here looking for a reason for your ResourceNotFound error your search may have just started.  I've encountered this for having my Cloud project settings configured for "DataConnection" where the app was looking for "DataConnectionString" and not deriving my table class from TableServiceEntity.  Today I'm getting it because of an InvalidOperationException.

With a basic understanding under my belt for adding a table and record to Azure it is time to build base classes for CRUD operations.   The perfect starting point for this seems to be the PersonalWebSite application from the Windows Azure Platform Training Kit as it holds the code for all basic operations.   I loaded the solution and executed it to receive the following message:


Figure A. 

I find as I step through the code that the Global.asax is attempting to access roles Administrators, Friends and admin - if they don't exist it will create them.   THE PROBLEM IS that if the role doesn't exist, the linq query (Figure C line 480) throws an actual invalid operation error - NOT - a DataServiceClientException as expected.   To verify this I clicked on the ASP.NET Configuration button (arrow in Figure B, which is configured in Web.Config to use TableStorageRoleProvider) and added the Administrators role - it worked as expected and then crashed on the Friends role.

Figure B.  
Figure C.

It appears that DataServiceClientException is derived from InvalidOperation but in our case the error is an actual InvalidOperationException as shown below - the code will never return false allowing continued operation of the program which will create the role.  

With the above problem resolved I ran into authentication errors.   This led to other errors which I confirmed to be incompatibility with the Visual Studio 2010 RC.

Excerpt from http://msdn.microsoft.com/en-us/library/dd573348.aspx follows:

Note The samples included with the Windows Azure SDK will not run on the Microsoft Visual Studio 2010 CTP. New samples for the Microsoft Visual Studio 2010 CTP are available for download. These samples run only in the Microsoft Visual Studio 2010 environment.

We'll see if they run on in the Visual Studio 2010 RC environment.

---------------------------------

From: Chris Mullins [mailto:xxxxxxx@microsoft.com]
Sent: Tuesday, March 30, 2010 5:12 PM
To: bill@global-webnet.com
Subject: Suggestion:Azure error

This is related to your post at:
http://www.global-webnet.net/blogengine/post/2010/02/13/Azure-error-Resource-not-found-catch-all-error.aspx

A workaround I’ve been using, has been to append the “&& true” to the end of the query. This allows the following code to work as you would expect rather than having the issue.

internal UnclaimedTokenEntity TryGetUnclaimedToken(string token)
        {
            try
            {
                // Note the '&& True' hack at the end. Ick. Without this, an exception is thrown if the row
                // doesn't exist.
                var result = from c in this.UnclaimedTokensTable
                             where c.PartitionKey == token && c.RowKey == token && true
                             select c;

                return result.FirstOrDefault();
            }
            finally
            {
                /// …           
}
        }

I hope this help you a little bit…


--
Chris Mullins


Tags: ,
Categories: Azure


Actions: E-mail | Permalink |  Grammar/Typo/Better way? Please let me know