我有一个天蓝色的移动服务,可以在某个时候上线。所以我需要创建指向UAT和dev数据库的UAT和dev版本。我正在努力的是如何创造这些。
我的live,UAT和Dev数据库中的命名空间需要相同,但如果我创建一个名为myAppName_UAT的新移动服务,它将要使用MyAppName_UAT作为命名空间,因此找不到任何表。 / p>
有没有人克服过这个问题?一旦产品上线,我需要能够针对Dev db测试移动应用程序而不影响实时情况,这肯定是常见的情况吗?
非常感谢任何建议。
编辑:我特别关注的是如何管理Azure门户中的多个环境。我可以部署我的UAT环境的所有其他组件,但我仍然停留在移动服务上。
我不是要求我的应用程序切换配置文件或在数据库之间迁移数据。有没有人有过使用多个组件运行多个移动服务的azure应用程序的经验?
答案 0 :(得分:1)
您使用版本控制吗?对我来说,你只需要创建分支来分离'UAT'和'dev'版本。
关于数据库:
您可以使用web.config转换来切换数据库之间的连接字符串。
http://msdn.microsoft.com/en-us/library/dd465326.aspx
How do I use Web.Config transform on my connection strings?
=================================================================================
更新
好的,现在我明白了你想要的东西。
创建两个版本的移动服务:
1-Log in Windows Azure Management Portal (http://manage.windowsazure.com)
2-Create your test mobile services (if you already have then, skip this step):
2.1- New -> Compute -> Mobile Services
2.2- Url - MyMobileServicesTest
2.3- Database -> Create a new (test db).
3-Create your production mobile services (if you already have then, skip this step):
2.1- New -> Compute -> Mobile Services
2.2- Url - MyMobileServicesProduction
2.3- Database -> Create a new (production db).
目前,您有两个不同的版本。
使用Windows Azure SDK:
//public static MobileServiceClient MobileService = new MobileServiceClient(
// "AppUrl",
// "AppKey"
//);
注意:AppUrl将是“MyMobileServicesTest.azure-mobile.net/”或“MyMobileServicesProduction.azure-mobile.net/”。应用密钥,每个环境都有它自己的。您可以将此设置存储在配置文件中,并根据您的操作进行切换。
更多信息:
http://www.windowsazure.com/en-us/develop/mobile/tutorials/get-started-with-data-dotnet/
答案 1 :(得分:0)
多个移动服务可以共享同一个数据库。您只需要在每个移动服务中的web.config中指定相同的模式名称:
<appSettings>
<add key="MS_MobileServiceName" value="MyAppName" />
</appSettings>
<强>更新强>
上述设置仅适用于localhost,但在发布后才能生效。
需要做以下技巧才能使其工作。只需将模式名称硬编码到函数OnModelCreating
中即可。这样,数据库模式名称将不再依赖于移动服务名称:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
string schema = "MyAppName"; // ServiceSettingsDictionary.GetSchemaName();
if (!string.IsNullOrEmpty(schema))
{
modelBuilder.HasDefaultSchema(schema);
}
modelBuilder.Conventions.Add(
new AttributeToColumnAnnotationConvention<TableColumnAttribute, string>(
"ServiceTableColumn", (property, attributes) => attributes.Single().ColumnType.ToString()));
}