【发布时间】:2018-01-16 21:11:37
【问题描述】:
拥有一个 ASP.NET webforms 应用程序,我使用在 SQL 服务器中创建的 aspnetdb 数据库。
迁移到 Azure 时,是否有任何方法可以将 aspnetdb 数据库替换为其他东西,这样它就不会占用 Azure SQL 数据库组件中的一个数据库?还是以某种方式支持特定数据库作为应用服务(Azure 组件)的一部分?
在使用 Azure 应用服务时,aspnetdb 数据库的典型替换形式是什么?
更新:在原始应用程序中,我在 MS SQL 标准版中使用了两个数据库。 -- 通常像company_users(这是aspnetdb 的名称)和应用程序表的company_app。我通常通过一个小型外部应用程序创建company_users,该应用程序创建数据库、角色以及初始用户——请参阅下面的缩短代码。
因此,将这两个数据库迁移到 Azure SQL 数据库并以相同的方式使用它可能会更直接。另一方面,必须根据数据库的数量为 Azure SQL 付费。虽然company_app 很好,但company_users 相当小,可能值得用更便宜的东西代替。这是将框架的身份验证/授权部分(aspnetdb 别名 company_users)替换为不会占用一个 SQL 数据库的其他东西的动机。
我的InitUsers.exe的缩短源代码:
// ... get the configuration information to be used for...
SqlServices.Install(SQLServerName,
SQLServerUser, SQLServerPassword,
ASPNETdbName, SqlFeatures.All);
// ... and the roles in the loop...
SqlRoleProvider roleProvider = AModule.GetRoleProvider();
string[] roles = { "admin", "poweruser", /* ... */ };
foreach (var role in roles) {
if (!roleProvider.RoleExists(role))
roleProvider.CreateRole(role);
}
// ... and the initial users...
List<string[]> userList = new List<string[]> {
// 0 1 2 3 4 5 6
// login, email, roles, first, last tit., phone
new[] { "nemo", "nemo@ocean.org", "admin", "Nihil", "Nemo", "cpt.", "123 456 789"}
};
foreach (var info in userList) {
string login = info[0];
string password = ...;
string email = info[1];
string[] rolenames = info[2].Split();
string first = info[3];
string last = info[4];
string title = info[5];
string phone = info[6];
AModule.MakeUser(login, password, email, rolenames,
first, last, title, phone,
true); // isApproved
}
【问题讨论】:
标签: azure-web-app-service aspnetdb