Set Up Umbraco in Visual Studio with LocalDB and Deploy to Azure

February 27, 2015 by Christopher Sherman

Since Microsoft has deprecated SQL Server Compact, it makes sense to transition your Umbraco development environment to a supported database solution. In this tutorial, I’ll first explain how to configure an Umbraco CMS project in Visual Studio using LocalDB for development. Next, I’ll show you how to deploy the project to Microsoft Azure Websites using an Azure SQL Database.

To get started, you’ll need Visual Studio and SQL Server Management Studio 2014 (SSMS). You can download Visual Studio and SSMS for free. You will also need to establish a Microsoft Azure account. Let’s get started.

Configure the Development Environment

Open SSMS and enter (localdb)\v11.0 as the server name and select Windows Authentication to connect.

In the connection pane that appears, right-click on Databases and select New Database. Name the database umbraco_localdb and click OK.

Open Visual Studio and create a new ASP.NET Web Application, selecting the Empty template.

On the main menu, select Tools > NuGet Package Manager > Package Manager Console. In the console type the following command to install the Umbraco CMS:

Install-Package UmbracoCms

Press Ctrl-F5 to run your application without debugging. In the menu that appears in your browser, enter your name, email, and password, and then click Customize. This is where we set the database to use LocalDB.

In the Database type field, select Microsoft SQL Server. In the server field, enter (localdb)\v11.0, and, in the name field, enter umbraco_localdb. Select the checkbox to use integrated authentication and click to continue. For the purpose of this tutorial, I will select the first starter kit template on the next page and continue.

Once Umbraco finishes initializing, you will have a functioning development environment. At this point I’ll assume we’ve applied any necessary customizations and are ready to deploy to Microsoft Azure.

Deploy to Microsoft Azure

In order to deploy, we need to migrate our database to Azure. Open the online Azure management portal and select the SQL Databases menu item. Choose the Servers menu tab, click New at the bottom left, and complete the prompts to create your server.

With the server created, navigate to the server’s dashboard and click the Configure menu tab. You will see your IP address and you need to click the button to add it to the allowed IP addresses. This will allow us to connect to the server through SSMS without the firewall blocking the connection.

Next, click the Websites section of the management portal main menu in the portal and select New > Quick Create and complete the form to create a website.

Now, open SSMS and, in the server name field, enter your_database_sever_name.database.windows.net (you need to replace the first subdomain to match your server in Azure). In the authentication section, enter the credentials you established when creating the server in the Azure management portal. Click connect. You should see your server appear in the object explorer pane.

In the object explorer pane of SSMS, click the connect dropdown and select database engine. In the Server name field, enter (localdb)\v11.0 and choose Windows Authentication in the authentication dropdown.

Expand the LocalDB connection in the object explorer, followed by the databases folder. Right-click on the umbraco_localdb database we created earlier. Select Tasks > Deploy Database to Window Azure SQL Database.

In the deployment settings panel, click connect and select your Azure server from the server name dropdown. Enter your credentials and click connect. You can leave the default values and click next. Click finish to migrate your database to Azure.

Now it’s time to return to Visual Studio and deploy our site. To publish your project, right-click on the project name in Visual Studio and select Publish. Click Microsoft Azure Websites as your publish target. Note that you may have to sign in at this point. In the existing websites dropdown, select the website we created earlier in the Azure management portal.

In the Publish Web window that appears, select Next to navigate to the Settings section and select the database we created in the Azure management portal from the dropdown beneath the umbracoDbDSN heading. Finally, click Publish to launch your site on Azure!

Umbraco Microsoft Azure