Share via


Using the Sample Windows Azure ASP.NET Providers

Previously, the sample Windows Azure ASP.NET providers were included in the samples folder that was installed with the SDK.

As of the November 2009 release of the Windows Azure Tools & SDK, this is no longer the case.  The samples are available online at https://code.msdn.microsoft.com/windowsazuresamples.

To use these samples:

1. Download the samples and unzip (These are no longer included as part of the samples installed to the SDK folder)

2. Add the AspProviders/Lib/AspProviders.csproj project to the solution by right clicking on the solution and selecting Add | Existing Project… and navigating to the AspProviders.csproj file.

3. Add a reference from your ASP.NET MVC 2 Web role to the AspProviders sample library by right clicking on the “references” folder in the ASP.NET MVC project and selecting “Add Reference…”

image

and selecting the AspProviders assembly:

image

4. Open the web.config file and add/change the providers. 

You can set the applicationName appropriately for your application. 

These sections are added under the system.web element. Note that I'm still tracking down some issues I'm seeing with the profile provider, will update this post when I know more.

Membership Provider:

     <membership defaultProvider="TableStorageMembershipProvider" userIsOnlineTimeWindow = "20">
      <providers>
        <clear/>

        <add name="TableStorageMembershipProvider"
             type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageMembershipProvider"
             description="Membership provider using table storage"
             applicationName="AspProvidersDemo"
             enablePasswordRetrieval="false"
             enablePasswordReset="true"
             requiresQuestionAndAnswer="false"
             minRequiredPasswordLength="1"
             minRequiredNonalphanumericCharacters="0"
             requiresUniqueEmail="true"
             passwordFormat="Hashed"
                />

      </providers>
    </membership>

Role Manager Provider:

   <roleManager enabled="true" defaultProvider="TableStorageRoleProvider" cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="30"
                 cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration = "true"
                 cookieProtection="All" >
      <providers>
        <clear/>
        <add name="TableStorageRoleProvider"
             type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageRoleProvider"
             description="Role provider using table storage"
             applicationName="AspProvidersDemo"
                />
      </providers>
    </roleManager>

Session State Provider:

         <sessionState mode="Custom" customProvider="TableStorageSessionStateProvider">
            <providers>
                <clear />
                <add name="TableStorageSessionStateProvider"
                     type="Microsoft.Samples.ServiceHosting.AspProviders.TableStorageSessionStateProvider"
                     applicationName="AspProvidersDemo"
             />
            </providers>
        </sessionState>

Change the existing appSettings element and the folllowing provider configuration:

   <appSettings>
    <add key = "TableStorageEndpoint" value="https://127.0.0.1:10002/devstoreaccount1"/>
    <add key = "BlobStorageEndpoint" value="https://127.0.0.1:10000/devstoreaccount1"/>
    <add key = "AccountName" value="devstoreaccount1"/>
    <add key = "AccountSharedKey" value="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="/>

    <!-- provider configuration -->
    <!-- When using the local development table storage service only the default values given
     below will work for the tables (Membership, Roles and Sessions) since these are the names
     of the properties on the DataServiceContext class -->
    <add key = "DefaultMembershipTableName" value="Membership"/>
    <add key = "DefaultRoleTableName" value="Roles"/>
    <add key = "DefaultSessionTableName" value="Sessions"/>
    <add key = "DefaultProviderApplicationName" value="ProviderTest"/>
    <add key = "DefaultProfileContainerName"/>
    <add key = "DefaultSessionContainerName"/>
  </appSettings>

You can now remove the “ApplicationServices” connection string as all of the providers that referenced it are gone.

6. Hit F5 to debug the application and your application is now using the sample ASP.NET providers that run against Windows Azure storage!

What’s next?  You can bet that we’ll put some more work into these providers to make them better and potentially even provide them as a real library. 

Stay tuned.

Comments

  • Anonymous
    January 01, 2010
    The comment has been removed

  • Anonymous
    January 05, 2010
    Clement - can you provide me a code sample of the issue you are seeing?

  • Anonymous
    January 06, 2010
    Hi, I've been trying to get this sample to work using development storage. It seems like blobs with session data are not being removed from the container after user logs out (Session.Abandon() is called). Debugging shows that IEnumerable<IListBlobItem> object returned by CloudBlobContainer.ListBlobs() times out when trying to enumerate over blobs to be deleted. Has anyone experienced similar behavior?

  • Anonymous
    January 16, 2010
    Yes, it seems that session data stored in the blobs, are not being removed, and just keeps on growing and growing.

  • Anonymous
    February 19, 2010
    Samples link in step 1 is broken.  Proper link is: http://code.msdn.microsoft.com/Project/Download/FileDownload.aspx?ProjectName=windowsazuresamples&DownloadId=8221

  • Anonymous
    February 22, 2010
    paulenfield -- thank you, I've updated the link.

  • Anonymous
    February 24, 2010
    Hello jnak! Do you have any information, on what's happening with the AspProvider sample, any updates coming soon or anything?

  • Anonymous
    February 25, 2010
    azurebright - it's on the list, no plans I can share at this point.

  • Anonymous
    June 09, 2010
    Feels wired to reference "Samples". I would love to see MS opensource these providers, or at least name their namespaces better.. Not to mention the "googleblity", seems that google ignores code.msdn.microsoft.com completely

  • Anonymous
    June 09, 2010
    Hi Carl, great feedback.  We're in the process of figuring out how to support ASP.NET providers in a first class manner and your feedback helps us to prioritize the scenario.

  • Anonymous
    June 29, 2010
    The comment has been removed

  • Anonymous
    June 29, 2010
    I am getting the following error in the application. Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode. Could you please provide the solution.

  • Anonymous
    July 06, 2010
    Vijay - off hand it sounds like you are trying to save an object that doesn't support serialization.  Does the problem occur with the standard providers and SQL Express or is this related only to using the Azure providers?

  • Anonymous
    August 13, 2012
    Hi, it is possible to deploye html5 pahes in windows azure? it's possible plz tell me process plz help me