如何配置ASP.NET Web应用程序使之使用Azure SQL Database
来源:互联网 发布:网络营销策划文案 编辑:程序博客网 时间:2024/06/05 07:14
1. 首先你需要添加一个程序包到你的ASP.NET项目中。右键点击你的ASP项目,选择Add Library Package Reference:
注意:这里的MigrateASPWebsiteAzure只是一个例子,请在Visual Studio中选择你将要配置的ASP.NET项目。
2. 在打开的对话中,搜索"Microsoft.AspNet.Providers", 然后选择"Microsoft.AspNet.Providers"进行安装。
现在我们已经为配置Azure SQL Database做好了准备。我们需要拿到Windows Azure SQL Database的连接字符串。要拿到这个连接字符串,请完成下面的步骤:
3. 登陆Windows Azure管理平台,点击你的SQL Database实例,进入Dashboard界面。在页面的右边,点击"Show Connection Strings"。参考下图:
把ADO.NET的Connection String拷贝到记事本里。
4. 现在回到Visual Studio中,打开项目中Web.config -> Web.Release.config文件。在<Configuration>元素中,添加你的ConnectionString.
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> <!-- In the example below, the "SetAttributes" transform will change the value of "connectionString" to use "ReleaseSQLServer" only when the "Match" locator finds an atrribute "name" that has a value of "MyDB". <connectionStrings> <add name="MyDB" connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings> --> <connectionStrings> <add name="AzureDB" connectionString="Server=tcp:h22qoc91jz.database.windows.net,1433;Database=[SopDB];User ID=azureuser@h22qoc91jz;Password={your_password_here};Trusted_Connection=False;Encrypt=True;Connection Timeout=30;" xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/> </connectionStrings>
请注意,上面只是一个例子,并不是Web.Release.config文件的全部内容。另外,你需要将ConnectionStrings中的{your_password_here}替换成真正的密码。
之后,再按照上一篇文章中的方法发布你的应用即可。
参考:
- Migrating an on-premise database from SQL Server to SQL Azure using SSIS
- 如何配置ASP.NET Web应用程序使之使用Azure SQL Database
- 将ASP.NET Web应用程序部署到Windows Azure Web Site和SQL 数据库
- 将ASP.NET Web应用程序支配到Windows Azure Web Site和SQL 数据库
- ASP.NET 2.0使用Web Part创建应用程序之二
- ASP.NET 2.0应用程序添加ASP.NET AJAX 组件引用之web.config配置
- 如何发布ASP.NET web应用程序
- 如何使用VS发布ASP.NET应用到Windows Azure
- 使用ASP.NET跟踪Web应用程序
- 使用ASP.NET跟踪Web应用程序
- 使用记事本开发ASP.NET web应用程序
- ASP.NET中使用web.config配置web应用程序中的数据库连接
- ASP.NET中使用web.config配置web应用程序中的数据库连接
- ASP.NET中使用web.config配置web应用程序中的数据库连接
- ASP.NET中使用web.config配置web应用程序中的数据库连接
- ASP.NET中使用web.config配置web应用程序中的数据库
- 部署一个安全的ASP.NET MVC 5应用程序成员、OAuth和SQL Azure网站数据库
- 将 ASP.NET 2.0 应用程序服务配置为使用 SQL Server 2000 或 SQL Server 2005
- 将 ASP.NET 2.0 应用程序服务配置为使用 SQL Server 2000 或 SQL Server 2005
- 如何从javascript直接调用word插件
- 快速的字符串查找算法(Boyer-Moore)
- Linux 共享库高级主题
- 制作镜面反射脚本
- MySQL自动测试框架介绍
- 如何配置ASP.NET Web应用程序使之使用Azure SQL Database
- 思科网络实验室路由交换实验指南读书笔记阶段总结1
- ORA-28000: the account is locked-的解决办法
- 实现一个应用程序:从终端接收不确定个数的字符串,并根据这些字符串建立链表
- 第四章 JavaFx 文本处理
- openstack中的aggregate az, cell, region ( by quqi99 )
- FormatMessage 用法
- 黑马程序员——java编程那些事儿____网络编程
- Android之SurfaceView学习(一)