Dışarıya aktar (0) Yazdır
Tümünü Genişlet
EN
Bu içerik dilinizde bulunmamaktadır ancak İngilizce sürümüne buradan bakabilirsiniz.

How to: Prepare Visual Studio to use Azure Shared Caching

Updated: June 19, 2014

ImportantImportant
Please note the Azure Shared Caching service will be retired on September 1, 2014 and with it the Azure Silverlight-based portal. Once the Shared Caching service is retired, all remaining Shared Cache deployments will be deleted. Microsoft strongly encourages you to migrate at the earliest opportunity all existing Shared caches to either the Managed Cache Service (currently in GA) or to the new Azure Redis Cache (currently in Preview). For migration guidance, including guidance for migrating without making code changes, see Migrate from Shared Caching. For more information about the current Azure Cache offerings, see Azure Cache.

This topic explains how to prepare a Visual Studio 2012 project to use Microsoft Azure Shared Caching. This includes the following tasks:

  • Verify that the correct version of the .NET Framework is targeted.

  • Reference the Shared Caching assemblies.

After these tasks, you can configure your cache client in the dataCacheClient section of the application or web.config files. This enables you to use the caching methods in the Microsoft.ApplicationServer.Caching namespace.

WarningWarning
You should not install Microsoft AppFabric 1.1 for Windows Server and Microsoft Azure Cache on the same machine. This includes both the product and the SDK. It is possible to mistakenly reference some of the Microsoft AppFabric 1.1 for Windows Server assemblies in the Global Assembly Cache. This could lead to incorrect or unexpected behavior.

To target the correct version of the .NET Framework

  1. Open your Visual Studio 2012 project.

  2. In Solution Explorer, right-click the project name and then select Properties.

  3. For a Visual C# project, use the following steps:

    1. Select the Application tab of the Project Properties dialog.

    2. Verify that the target framework version is .NET Framework 2.0 or higher (non-client profile).

  4. For a Visual Basic project, use the following steps:

    1. Select the Compile section of the Project Properties page.

    2. At the bottom of the Compile page, click the Advanced Compile Options button.

    3. Verify that the target framework version is .NET Framework 2.0 or higher (non-client profile).

ImportantImportant
Do not use the client profile for the target framework version. In Visual Studio, select .NET Framework versions that do not specify "Client Profile".

Configure a Project for Shared Caching

To add the assembly references, you must have the SDK installed on your machine. For instructions, see Azure SDK Download.

The following steps use a NuGet package to add the necessary assembly references and configuration changes. These steps are specific to using Shared Caching.

  1. In Solution Explorer, right-click on the project name, and then select Add Library Package Reference (NuGet 1.2) or Manage NuGet Packages (NuGet 2.0).

  2. In the left pane, select the Online category.

  3. Search for WindowsAzure.Caching.

  4. Install the In-Role Cache package named WindowsAzure.Caching (NuGet 1.2) or Azure Shared Caching (NuGet 2.0).

    Screenshot of Shared Caching Package (NuGet 1.2)

    Screenshot of Shared Caching Package (NuGet 2.0)

In addition to adding the appropriate assembly references, this package also modifies the configuration file (app.config or web.config) for the targeted project. It adds a boilerplate dataCacheClients section similar to the following.

<dataCacheClients>
  <dataCacheClient name="default">
    <hosts>
      <host name="[Insert Cache EndPoint]" cachePort="22233" />
    </hosts>
    <securityProperties mode="Message">
      <messageSecurity authorizationInfo="[Encrypted ACS token goes here]"></messageSecurity>
    </securityProperties>
  </dataCacheClient>
  <dataCacheClient name="SslEndpoint">
    <hosts>
      <host name="[Insert Cache EndPoint]" cachePort="22243" />
    </hosts>
    <securityProperties mode="Message" sslEnabled="true">
      <messageSecurity authorizationInfo="[Encrypted ACS token goes here]"></messageSecurity>
    </securityProperties>
  </dataCacheClient>
</dataCacheClients>

The final step is to replace the placeholder values of [Insert Cache EndPoint] and [Encrypted ACS token goes here]. These values are obtained from the . Note that you cannot see Shared Caching information in the new . You must switch back to the old portal to get this information. For more information, see How to: Configure a Cache Client using the Application Configuration File (Azure Shared Caching). It is also possible to programmatically configure access to the cache. For more information, see How to: Configure a Cache Client Programmatically (Azure Shared Caching).

The NuGet package adds references to the following assemblies:

  • Microsoft.ApplicationServer.Caching.Client

  • Microsoft.ApplicationServer.Caching.Core

  • Microsoft.Web.DistributedCache

  • Microsoft.WindowsFabric.Common

  • Microsoft.WindowsFabric.Data.Common

noteNote
It is possible to manually reference these assemblies without the NuGet package. By default, they are installed to C:\Program Files\Microsoft SDKs\Microsoft Azure\.NET SDK\2012-10\ref\SharedCaching.

See Also

Topluluk İçeriği

Ekle
Show:
© 2014 Microsoft