如何使用 Azure 上的 MVC2 应用程序管理和发布数据库?

发布于 2024-09-29 08:36:51 字数 617 浏览 0 评论 0原文

首先我要说的是,我对将应用程序部署到云的想法还很陌生,但我最近下载了 Azure SDK,并希望构建一个示例应用程序来让自己跟上进度。这就是我所做的。

  1. 下载 Azure SDK
  2. 创建新解决方案
  3. 添加新的 ASP.NET MVC2 Web 角色
  4. 编译
  5. 调试

当我在本地处于调试模式时,一切似乎都工作得很好 — 我可以创建用户、登录并单击。但是,当我部署解决方案时,我感觉数据库没有部署。我知道 SQL Azure 的工作方式与 SQL Express 不同,所以我有几个问题。

  1. ASP.NET MVC2 Web 角色及其随附数据库是否适合部署到 Azure?
  2. 如何将我的数据库“转移到云端”?
  3. 管理架构和查找数据以部署到 SQL Azure 的最佳方法是什么?

在寻找解决方案时,令我印象深刻的一件事是,Azure 没有大量优秀的文档——我发现的所有教程都是旧的或针对测试版的。帮助!

编辑:对我来说,理想的解决方案不需要每次部署时都打开 SQL Server Management Studio 导出架构/数据脚本。当然还有比这更好的方法吗?

I'll start by saying that I'm fairly new to the idea of deploying applications to the cloud, but I recently downloaded the Azure SDK and wanted to build a sample application to get myself up-to-speed. Here's what I did.

  1. Download the Azure SDK
  2. Create a new solution
  3. Add a new ASP.NET MVC2 Web Role
  4. Compile
  5. Debug

Everything seems to work just fine when I am in debug mode locally--I can create users, log in, and click around. When I deploy my solution, though, I feel like the database is not getting deployed. I understand that SQL Azure works differently from SQL Express, so I have a few questions.

  1. Is the ASP.NET MVC2 Web Role with its accompanying database meant for deployment to Azure?
  2. How can I get my database "into the cloud"?
  3. What is the best way to manage my schema and lookup data for deployment to SQL Azure?

One thing that struck me while I was searching for a solution is that there is not a wealth of good documentation for Azure--all of the tutorials I found are old or targeted at betas. Help!

Edit: The ideal solution to me does not involve opening SQL Server Management Studio to export my schema/data scripts every time I want to deploy. Surely there is a better way than this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼眸 2024-10-06 08:36:51

部署到 SQL Azure 与部署到运行 SQL Server 标准版或企业版的单独 SQL Server 计算机没有什么不同。这与部署到也运行 SQL Server Express 的 Web 服务器不同,后者允许您将 MDF 文件打包为 ASP.NET 应用程序的一部分,但这是设计使然。有可用的工具,但您也可以编写对数据库的更改的脚本(手动或自动)。

另一种可能的自动化部署方法是利用 SQL Azure 迁移向导,但这仍然需要一些操作设置(它更适合一次性迁移)。

Deploying to SQL Azure is no different than it would be when you are deploying to a separate SQL Server machine running SQL Server Standard or Enterprise edition. This is different from deploying to a web server that is also running SQL Server Express, that allows you to package an MDF file as part of the ASP.NET app, but that is by design. There are tools available, but you could also script the changes to the database (either by hand or automatically).

Another possible way of automating the deployment is by leveraging the SQL Azure migration wizard, but that will still require a bit of setting up (it is more geared towards 1-time-only migrations).

如梦 2024-10-06 08:36:51

我强烈建议您在本地 SQL 服务器下进行开发,并通过 Red Gate 工具将更改部署到 Azure:SQL Compare 和 Data Compare v9 beta。在这方面他们是“最优秀的”。

另外,请关注这个免费工具:http://www.microsoft.com /en-us/sqlazure/datasync.aspx
它承诺在 SQL 数据库的本地版本和 Azure 版本之间进行数据同步。

希望这有帮助

I highly recommend you develop under local SQL server and deploy your changes to Azure via Red Gate tools: v9 beta of the SQL Compare and Data Compare. They are "most excellent" in this regard.

Also, keep an eye on this free tool: http://www.microsoft.com/en-us/sqlazure/datasync.aspx
It promises to do a data-sync between local and Azure versions of a SQL database.

Hope this helps

柠北森屋 2024-10-06 08:36:51

我最终做了一些更多的研究并与同事讨论。我们得出的结论是,没有像传统方式那样管理数据库的好方法,但您可以按照下面概述的流程进行操作。

  • 使用 SQL Server Management Studio 2008 R2 连接到 SQL Azure
  • 使用 Visual Studio 中的普通 SQL Server 数据库项目构建数据库
  • 将数据库导出到 SQL Azure...
    • 将 SQL Azure 数据库部署为新数据库
    • 将数据从旧数据库复制到新数据库
    • 删除旧数据库

这大概是目前最好的情况。您也可以使用数据层应用程序,它本质上做同样的事情。

I ended up doing some more research and discussing with coworkers. We came to the conclusion that there is no great way to manage databases as one traditionally would, but you can follow the process outlined below.

  • Use SQL Server Management Studio 2008 R2 to connect to SQL Azure
  • Construct your database using a normal SQL Server database project in Visual Studio
  • To export the database to SQL Azure...
    • Deploy the SQL Azure database as a new database
    • Copy your data from the old database to the new database
    • Delete the old database

This is about the best it is going to be for now. You can alternatively use a Data Layer application, which essentially does the same thing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文