다음을 통해 공유


Windows Server AppFabric How-To: Adding multiple persistence stores to an AppFabric installation

Yesterday someone contacted me in regards to adding a secondary persistence store to their AppFabric installation – they were trying to configure the environment so that workflow service A persists its instances to Store A, while workflow service B persists to Store B. Simple enough, right? Well, I realized that there was no documentation on how exactly to achieve this configuration. So, here you go…

Manual registration of additional persistence stores

  1. The first step of course, is to physically create and initialize a persistence database. Start the Configure AppFabric wizard, and select next to go to the Hosting Services config page. Tick the Set persistence configuration checkbox, select sqlStoreProvider as the Persistence provider, and click the Configure button:

  2. In the Persistence Store Configuration window, tick the Initialize persistence store checkbox, specify the Server and Database names for the new persistence database, and then click OK:

    Note: Do no tick the "Register AppFabric persistence store in root web.config" checkbox – we will add the required entries manually.

  3. Now, if you open your root web.config, towards the end of the file you will find a section that "declares" the instance stores that AppFabric knows about. Here's an extract with the default config from my machine:

  4. To declare a new persistence store, you should create another <add> element under <instanceStores> . Note that you will also need to define a corresponding connection string under the <connectionStrings> element a bit further down in the file. Your modified web.config file should look similar to:

  5. Save the file. You now have a second persistence store that you can use for your workflow services.

Scripted Version

To perform the above tasks you can also use the AppFabric PowerShell cmdlets as follows:

  1. Start a PowerShell cmd window with elevated privileges and import the AppFabric management module:

    import-module ApplicationServer

  2. Create and initialize a new persistence database using the Initialize-ASPersistenceSqlDatabase cmdlet:

    Initialize-ASPersistenceSqlDatabase –Database "NewDB" –Server "NewDBServer\SQLEXPRESS" –Admins "Domain\AppServerAdmins" –Readers "DOMAIN\AppServerReaders" –Users "DOMAIN\AppServerUsers"

    Note: The user groups you specify for the –Admins, –Readers, and –Users parameters will be specific to your environment

  3. Use the Add-ASAppSqlInstanceStore cmdlet to register the persistence store in the root web.config file:

    Add-ASAppSqlInstanceStore -Name secondarySqlPersistenceStore -ConnectionString "Data Source=sqlServerName2\SQLEXPRESS;Initial Catalog=NewDB;Integrated Security=True" –root

Here is the copy/paste-ready script:

import-module ApplicationServer
Initialize-ASPersistenceSqlDatabase –Database "NewDB" –Server "NewDBServer\SQLEXPRESS" –Admins "Domain\AppServerAdmins" –Readers "DOMAIN\AppServerReaders" –Users "DOMAIN\AppServerUsers"
add-ASAppSqlInstanceStore -Name secondarySqlPersistenceStore -ConnectionString "Data Source=sqlServerName2\SQLEXPRESS;Initial Catalog=NewDB;Integrated Security=True" –root

Final notes

The above steps register the new persistence store at the root level (through the root web.config file). This means that the new store will be available for use by all AppFabric applications running on machine. You may also choose to add a persistence store at a specific scope in the IIS application hierarchy. For the scripted version, the only difference will be in the parameters passed to the cmdlet in step 3 – the full list of parameters for the cmdlet is available on its documentation page.

Comments

  • Anonymous
    January 27, 2011
    Hi Emil,I just tried this out because I wanted to start 2 workflow projects and wanted for second one to use other persistence store. I did all steps, created additonal database with configuration tool of appfabric. This went fine. Then I added additional connection string and instance store in root web.config. I restarted the server and tried to configure persistence for selected site. I found Sql server store but also got following exception:"The connection string XY used by the current store cannot be found. Workflow instances will not persist. Please select another instance."But the connection string XY for sure exists in root web config and is used in additional instance store. Did I update some wrong web.config? I found web config under: C:WindowsMicrosoft.NETFramework64v4.0.30319Config. As you see I have 64 virtual machine but as I saw this config will be used by appfabric.My update look likes this:<connectionStrings>       <add connectionString="Data Source=.SQLEXPRESS;Initial Catalog=XYCatalog;Integrated Security=True;Persist Security=True" name="XY" />   </connectionStrings><microsoft.applicationServer>
        &lt;persistence&gt;        &lt;instanceStoreProviders lockItem=&quot;true&quot;&gt;            &lt;add name=&quot;SqlPersistenceStoreProvider&quot; storeProvider=&quot;Microsoft.ApplicationServer.StoreProvider.Sql.SqlWorkflowInstanceStoreProvider, Microsoft.ApplicationServer.StoreProvider, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; storeControlProvider=&quot;Microsoft.ApplicationServer.StoreManagement.Sql.Control.SqlInstanceControlProvider, Microsoft.ApplicationServer.StoreManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; storeQueryProvider=&quot;Microsoft.ApplicationServer.StoreManagement.Sql.Query.SqlInstanceQueryProvider, Microsoft.ApplicationServer.StoreManagement, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&quot; /&gt;        &lt;/instanceStoreProviders&gt;        &lt;workflowManagement&gt;            &lt;workflowManagementServiceInstances lockItem=&quot;true&quot;&gt;                &lt;workflowManagementServiceInstance name=&quot;&quot;&gt;                &lt;/workflowManagementServiceInstance&gt;            &lt;/workflowManagementServiceInstances&gt;        &lt;/workflowManagement&gt;
               <instanceStores>               <add name="XYSqlPersistenceStore" provider="SqlPersistenceStoreProvider" connectionStringName="XY" />           </instanceStores>
        &lt;/persistence&gt;    &lt;hosting&gt;        &lt;serviceManagement endpointConfiguration=&quot;ServiceManagementNetPipeEndpoint&quot; enabled=&quot;true&quot; authorizedWindowsGroup=&quot;AS_Administrators&quot; /&gt;    &lt;/hosting&gt;&lt;/microsoft.applicationServer&gt;
    I would appriciate any help!Kr,Dejan