0
votes

I am currently new to Azure and learning how to make simple web roles. I have installed the necessary SDKs. I have successfully created an application having one web role. I know how to migrate existing websites to azurewebsites and existing database to 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. I want to know can we use SQL Azure here? 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.

1

1 Answers

0
votes

Unlike Websites Web Roles do not include the option to create a database for you so you will need to create your database yourself.

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)