Adding,Removing, and Repositing apps is not currently available

在Storefront使用远程数据库进行部署的时候,我们发现,当正常配置完成以后,我们会发现,从网页登陆以后,一直提示以下错误:

add-remove-repositioning-apps

Adding,removing, and respositing apps is not currently available.Any changes you make will not be preserved for future sessions.Please contact your help desk.

在Event Log中,我们可以发现以下日志:

Warning	1/25/2013 7:41:25 PM	WebApplication	12	(2001)	Unable to make successful connection to data source using provider 'System.Data.SqlClient' and connection string 'Integrated Security=SSPI;Server=db.xenme.lab;Database=storefront'.
Error	1/25/2013 7:41:25 PM	WebApplication	8	(2003)	"Data source unavailable with connection string 'Integrated Security=SSPI;Server=db.xenme.lab;Database=storefront' and provider 'System.Data.SqlClient'
System.Data.EntityCommandExecutionException, System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
An error occurred while executing the command definition. See the inner exception for details.
   at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
   at System.Data.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)
   at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at System.Data.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__1[TResult](IEnumerable`1 sequence)
   at System.Data.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
   at System.Data.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[S](Expression expression)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
   at Citrix.DeliveryServices.DazzleResources.SubscriptionAdo.Models.Data.AdoSubscriptionsManager.ReadVersion()
   at Citrix.DeliveryServices.DazzleResources.SubscriptionAdo.Models.Data.AdoSubscriptionsManager..ctor(IIdGenerator idGenerator, String connectionString, String providerName)

System.Data.SqlClient.SqlException, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Invalid object name 'dbo.SchemaDetails'.
HelpLink.ProdName: Microsoft SQL Server
HelpLink.ProdVer: 10.50.1600
HelpLink.EvtSrc: MSSQLServer
HelpLink.EvtID: 208
HelpLink.BaseHelpUrl: http://go.microsoft.com/fwlink
HelpLink.LinkId: 20476
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
   at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
   at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
   at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.EntityClient.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)
"

在检查了数据库的连接以后,发现数据库的连接也没有问题。而在检查Exception的时候发现,应该是在执行某些命令(ExecuteStoreCommands)的时候发生异常,而检查数据库表的时候,我们发现,storefront的数据库表下没有创建表,而手动创建了表以后,一切恢复正常。

所以,总结下来,storefront使用远程的数据库需要进行以下步骤:

  1. 使用Management Studio创建数据库
  2. 使用以下脚本创建对应的Table
    /* 请替换下面的storefront为您自己的数据库的名称*/
    USE [storefront]
    
    /****** Object:  Table [dbo].[User]  ******/
    SET ANSI_NULLS ON
    
    SET QUOTED_IDENTIFIER ON
    
    CREATE TABLE [dbo].[User](
     [id] [int] IDENTITY(1,1) NOT NULL,
    	[username] [nvarchar](100) COLLATE latin1_general_CS_AS_KS NOT NULL,
    CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED 
    (
    	[id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
     IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = OFF) 
     ON [PRIMARY]
    ) ON [PRIMARY]
    
    CREATE UNIQUE NONCLUSTERED INDEX [username_idx] ON [dbo].[User] 
    (
    	[username] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
     SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, 
     ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = OFF) 
     ON [PRIMARY]
    
    /****** Object:  Table [dbo].[Subscription]  ******/
    SET ANSI_NULLS ON
    
    SET QUOTED_IDENTIFIER ON 
    
    CREATE TABLE [dbo].[Subscription](
     [id] [int] IDENTITY(1,1) NOT NULL,
     [subscription_ref] [varchar](32) COLLATE latin1_general_CS_AS_KS NOT NULL,
    	[resource_id] [nvarchar](400) COLLATE latin1_general_CS_AS_KS NOT NULL,
     [user_id] [int] NOT NULL,
    	[status] [int] NOT NULL,
    	[metadata] [nvarchar](max) NULL,
    	[secure_metadata] [nvarchar](max) NULL,
    CONSTRAINT [PK_subscriptions] PRIMARY KEY CLUSTERED 
    (
     [id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
     IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = OFF) 
     ON [PRIMARY]
    ) ON [PRIMARY]
    
    CREATE UNIQUE NONCLUSTERED INDEX [subscription_ref_idx] ON 
     [dbo].[Subscription]
    (
    [subscription_ref] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
     SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, 
     ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = OFF) 
     ON [PRIMARY]
    
    CREATE NONCLUSTERED INDEX [user_resource_idx] ON [dbo].[Subscription] 
    (
    [user_id] ASC,
    [resource_id] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, 
     SORT_IN_TEMPDB = OFF, IGNORE_DUP_KEY = OFF, DROP_EXISTING = OFF, 
     ONLINE = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = OFF) 
     ON [PRIMARY]
    
    /****** Object:  Default [DF_subscriptions_status] ******/
    ALTER TABLE [dbo].[Subscription] 
     ADD  CONSTRAINT [DF_subscriptions_status]  
     DEFAULT ((0)) FOR [status]
    
    /****** Object:  ForeignKey [FK_subscriptions_user_id] ******/
    ALTER TABLE [dbo].[Subscription]  
     WITH CHECK ADD  CONSTRAINT [FK_subscriptions_user_id] 
     FOREIGN KEY([user_id])
    REFERENCES [dbo].[User] ([id])
    
    ALTER TABLE [dbo].[Subscription] 
     CHECK CONSTRAINT [FK_subscriptions_user_id]
    
    CREATE TABLE [dbo].[SchemaDetails](
    	[major_version] [int] NOT NULL,
     [minor_version] [int] NOT NULL,
    	[details] [nvarchar](max) NULL
    ) ON [PRIMARY]
    
    INSERT INTO [dbo].[SchemaDetails] ([major_version], [minor_version]) 
     VALUES (1, 0)
  3. 使用Management Studio创建Security Login
  4. 设置该Login的权限为db_datawriter和db_datareader
  5. 配置storefront,创建store以及storeweb等等

如果希望全部通过脚本来实现,请参考以下链接:

http://support.citrix.com/proddocs/topic/dws-storefront-10/dws-deploy-multi-database.html

关于无法正常保存订阅结果的问题,还可能是SQL的一个Bug,请参考以下KB解决:

http://support.citrix.com/article/CTX133096