Using Existing Windows Azure SQL Databases with Azure Mobile Services

I was one of the speakers today at the 6 Weeks of Azure bootcamp event in Sydney today. During the day, as well as speaking, we have an "unconference". There's a lot of discussion on whatever the attendees want to discuss.

One of the offline questions I got today though was about how to hook up Azure Mobile Services to an existing Windows Azure SQL Database rather than using the one that Mobile Services can auto-create. While getting that to work, we learned a few things:

  • Tables need to be created in a schema that has the same name as the Mobile Service. (ie: if I want a table called CurrentTasks, and my service is called TaskManager, I need to have my table called TaskManager.CurrentTasks.
  • Tables need to have a clustered primary key that is an integer and is called "id" (it appears case-sensitive in the app for some reason)
  • After you modify the mobile service to point to your database (or after you create a mobile service referencing the existing database), you need to add each table to the service by using the mobile services portal. (If you reference a table that doesn't exist, that's when it would also create the table)

The attendee had already created his tables in the dbo schema. We moved his tables by using:

ALTER SCHEMA servicename TRANSFER dbo.OldTableName;

It's also worth noting that Mobile Services isn't yet available in all datacenters. The attendee's database was in a different datacenter and it's important to try to avoid that, or the latency can be a big issue. He and another attendee were asking about the best ways to move the database to another datacentre. One option for this is to export a BACPAC of the database to Azure Storage, and to then import the database to the alternate server.

Unfortunately, even though CREATE DATABASE AS COPY OF works across servers within the same datacenter, it doesn't work for servers in different datacenters.

 

Whitepaper editing

Hi Folks,

I posted a day or so back about the whitepaper on plan caching and recompilation being published.

Today I had a query from a reader and found that the editor has messed up an example.

For example, I had this example of a query that's almost identical but where the query plan would be different:

SELECT ProductID
FROM Sales.SalesOrderDetail
GROUP BY ProductID
HAVING AVG(OrderQty) > 5
ORDER BY ProductID;

SELECT productid
FROM Sales.SalesOrderDetail
GROUP BY ProductID
HAVING AVG(OrderQty) > 5
ORDER BY ProductId;

"Helpfully" the editor changed it to:

SELECT ProductID
FROM Sales.SalesOrderDetail
GROUP BY ProductID
HAVING AVG(OrderQty) > 5
ORDER BY ProductID;

SELECT ProductID
FROM Sales.SalesOrderDetail
GROUP BY ProductID
HAVING AVG(OrderQty) > 5
ORDER BY ProductID;

And undid the point of the example…

Whitepaper: Plan Caching and Recompilations in SQL Server 2012

Hi Folks,

Over the last year, I've been working on an update to the whitepaper Plan Caching in SQL Server 2008 as a background task.

A great group of reviewers have been involved at various stages during the process. Thank you to Paul White, Andrew Kelly, Kalen Delaney, and Rubén Garrigós from the SQL community, along with Leigh Stewart and Jack Li from the SQL Server product team for sharing your knowledge and ideas.

Gail Erikson from the SQL documentation team let me know today that the latest version Plan Caching and Recompilation in SQL Server 2012 is now available:

http://msdn.microsoft.com/en-us/library/dn148262.aspx

Enjoy!

 

SQL Down Under – Show 57 – Karen López – Data Modelling, Database Refactoring, Space Data, and Open Data

Hi Folks,

I got to record another podcast today. Show 57 features guest SQL Server MVP Karen López. Karen is well-known in the SQL Community, on her blog and is prolific on Twitter.

In the show, Karen discusses her experiences related to data modelling, including tools, round-tripping, traceability, and model-driven development. She also covers some common mistakes she encounters in this area. Later in the show Karen discusses the challenges in database refactoring, her interest in all things to do with space, and her interest in the open data movement.

The show is now available: http://www.sqldownunder.com/Resources/Podcast.aspx

Enjoy!

SQL Server BI Tooling now in Visual Studio 2012 Shell

This is really exciting. One of the complaints from those using the BI tools (SQL Server Data Tools) has been that they were tied to the Visual Studio 2010 shell, when the rest of their development work had moved to Visual Studio 2012.

The SQL Server BI team has now released the VS2012 versions of these project templates. You'll find details the download here:

http://www.microsoft.com/en-us/download/details.aspx?id=36843

The Reporting Services team blog about it is here:

http://blogs.msdn.com/b/sqlrsteamblog/archive/2013/03/06/sql-server-data-tools-business-intelligence-for-visual-studio-2012-released-online.aspx 

And the Analysis Services team blog about it is here:

http://blogs.msdn.com/b/analysisservices/archive/2013/03/06/sql-server-data-tools-business-intelligence-for-visual-studio-2012-released-online.aspx 

One nice aspect that I've found is that I have been able to open BI projects in VS2010 again, even after editing them in VS2012. I wasn't expecting that to be possible so it must mean that the project format hasn't changed.

One hint on installation though:

Make sure you choose the "New Instance" option (strange as that might seem). Otherwise, you'll get an error that says the following:

Rule "Same architecture installation" failed.

Enjoy!

Windows Azure SQL Reporting – now configurable in the new portal

Scott Guthrie blogged yesterday about a raft of new changes to the Azure platform.

Of interest to SQL folk are really three main changes:

* SQL Reporting has made its way into the new portal (ie: you no longer have to flip back to the old portal to work with it. Hopefully Data Sync will do the same soon).

* Better options now exist for downloading blobs from Azure Storage. (This could include, for example, SQL Server backups made using BACKUP TO URL).

* New tools for monitoring the usage and availability of VMs.

For others, it's good to see that you can now upload .cer certificate files, not just .pfx certificate files when working with cloud services, and also interesting to see Android support added to mobile services.

You'll find Scott's post here: http://weblogs.asp.net/scottgu/archive/2013/03/04/windows-azure-updates-android-support-sql-reporting-services-active-directory-more.aspx

SQL Down Under Show 56 – Thomas LaRock – DBAs moving to architect, constant learning, Azure, big data

I recorded another podcast today with Thomas LaRock, aka SQL Rock Star.

In this show, Tom and I discussed the migration of many DBAs into architect roles, the challenges in constant learning (and useful resources for doing so), the hype around big data, the role of Windows Azure in our future, and upcoming PASS events.

It's online now: https://www.sqldownunder.com/Resources/Podcast.aspx

Enjoy!