简体   繁体   English

Azure Web角色:使用数据库

[英]Azure Web Role : Using Database

I am currently new to Azure and learning how to make simple web roles. 我目前是Azure的新手,正在学习如何制作简单的Web角色。 I have installed the necessary SDKs. 我已经安装了必要的SDK。 I have successfully created an application having one web role. 我已经成功创建了一个具有Web角色的应用程序。 I know how to migrate existing websites to azurewebsites and existing database to SQL Azure. 我知道如何将现有网站迁移到azurewebsites和将现有数据库迁移到SQL Azure。

Question : 题 :

I want to know how do we use database in a web role? 我想知道我们如何在网络角色中使用数据库?

Currently my connection string looks like this: 目前,我的连接字符串如下所示:

Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-MTSWebRole-20150327120955;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-MTSWebRole-20150327120955.mdf"

But I think this is a local Database. 但是我认为这是一个本地数据库。 Q1. Q1。 I want to know can we use SQL Azure here? 我想知道我们可以在这里使用SQL Azure吗? Q2. Q2。 Also please let me know what happens when I publish this Application? 还请让我知道发布此应用程序时会发生什么? Does the database also gets created by default? 默认情况下还会创建数据库吗?

Any links which provides me the basic understanding will also be appreciated. 任何提供我基本理解的链接也将不胜感激。

Unlike Websites Web Roles do not include the option to create a database for you so you will need to create your database yourself. 与网站不同,Web角色不包括为您创建数据库的选项,因此您将需要自己创建数据库。

Once created simply extract the connection string for the database from the database dashboard in the Azure portal and replace the configured value through the websites configuration in the portal (and/or your web.config) 创建后,只需从Azure门户中的数据库仪表板中提取数据库的连接字符串,然后通过门户中的网站配置(和/或您的web.config)替换配置的值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM