<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Azure SQL EMEA Engineers</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/azuresqlemea/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/feed.xml</link>
    <description>Posts are provided by the Azure SQL Support Engineers team in EMEA</description>
    <lastBuildDate>Wed, 17 Apr 2019 03:06:47 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Lesson Learned #26: How to change the definition of table triggers at the same time</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/lesson-learned-26-how-to-change-a-multiple-table-triggers-definition-at-the-same-time</link>
      <pubDate>Mon, 10 Apr 2017 15:03:59 GMT</pubDate>
      <dc:creator><![CDATA[Jose M Jurado - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2175</guid>
      <description><![CDATA[Today, we have been working a very interesting case, when our customer is migrating their database...]]></description>
      <content:encoded><![CDATA[Today, we have been working a very interesting case, when our customer is migrating their database to Azure SQL Database.

We have found an incompatibility issue, because all triggers have an error handler with this syntax: <a href="https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql">raiserror </a>@errno @errmsg to inform the error happened, but, this syntax is not supported for Azure SQL Database.

To fix this problem, we need to replace the syntax <a href="https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql">raiserror </a>@errno @errmsg by, for example, <a href="https://docs.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql">raiserror</a>(@errno,-1,-1, @errmsg). Unfortunately, we have around 100 triggers to modify accordingly.

In this situation, we suggested the following script "as is - without any guarantee" in order to obtain the definition of all triggers to review it.

&nbsp;
<p style="padding-left: 30px">DECLARE @TRname nvarchar(MAX)</p>
<p style="padding-left: 30px">DECLARE @N as int</p>
<p style="padding-left: 30px">DECLARE vcursor CURSOR FOR select OBJECT_DEFINITION(OBJECT_ID(NAME)) AS xTriggerDefinitionx from sys.objects where type ='TR';</p>
<p style="padding-left: 30px">OPEN vcursor</p>
<p style="padding-left: 30px">FETCH NEXT FROM vCursor INTO @TRNAME</p>
<p style="padding-left: 30px">WHILE @@FETCH_STATUS = 0</p>
<p style="padding-left: 30px">BEGIN</p>
<p style="padding-left: 30px">    --PRINT @TRNAME</p>
<p style="padding-left: 30px">    SET @N = charindex('raiserror @errno @errmsg',@TRname)</p>
<p style="padding-left: 30px">    SET @Trname = REPLACE(@TRname,'CREATE TRIGGER','ALTER TRIGGER')</p>
<p style="padding-left: 30px">    If @n&lt;&gt; 0</p>
<p style="padding-left: 30px">      BEGIN</p>
<p style="padding-left: 30px">          SET @Trname = REPLACE(@TRname,'raiserror @errno @errmsg','raiserror(@errno,-1,-1, @errmsg)')</p>
<p style="padding-left: 30px">       END</p>
<p style="padding-left: 30px">     PRINT @TRNAME</p>
<p style="padding-left: 30px">      FETCH NEXT FROM vCursor INTO @TRNAME</p>
<p style="padding-left: 30px">END</p>
<p style="padding-left: 30px">CLOSE vcursor;</p>
<p style="padding-left: 30px">DEALLOCATE vcursor;</p>
&nbsp;

Enjoy!]]></content:encoded>
    </item>
    <item>
      <title>Connect from Power BI to Azure SQL Database using AAD authentication</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/connect-from-power-bi-to-azure-sql-database-using-aad-authentication</link>
      <pubDate>Thu, 06 Apr 2017 15:34:09 GMT</pubDate>
      <dc:creator><![CDATA[Beatriz Garcia Roces]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2127</guid>
      <description><![CDATA[Currently Power BI doesn’t support AAD authentication when connecting to Azure SQL Database, but...]]></description>
      <content:encoded><![CDATA[<span lang="EN-US"><span>Currently Power BI doesn’t support AAD authentication when connecting to Azure SQL Database, but using Microsoft ODBC Driver 13 it is possible to do it. </span></span>

<span lang="EN-US"><span>You can download the driver from </span></span><a href="https://www.microsoft.com/en-us/download/details.aspx?id=53339"><span lang="EN-US"><span>here</span></span></a><span lang="EN-US"><span> (ODBC Driver 13.1) and install it. </span></span>

<span lang="EN-US"><span>After installing the driver, you can connect to the Azure SQL using ODBC connector.</span></span>
<p style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2017/04/15.png"><img width="759" height="816" class="alignnone size-full wp-image-2135" alt="1" src="https://msdnshared.blob.core.windows.net/media/2017/04/15.png" /></a></p>
Select ODBC and introduce the connection string that should have the following format:
<p style="padding-left: 30px">Driver={ODBC Driver 13 for SQL Server};Server=tcp: &lt;Server Name &gt; ,1433;Database=&lt;Database name&gt;;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryPassword</p>
<p style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2017/04/22.png"><img width="721" height="492" class="alignnone size-full wp-image-2145" alt="2" src="https://msdnshared.blob.core.windows.net/media/2017/04/22.png" /></a></p>
<span lang="EN-US"><span>You will be requested to introduce the user and password for the database. </span></span>
<p style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2017/04/32.png"><img width="751" height="390" class="alignnone size-full wp-image-2155" alt="3" src="https://msdnshared.blob.core.windows.net/media/2017/04/32.png" /></a></p>
<span lang="EN-US"><span>You can find more information about AAD authentication and users </span><a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-aad-authentication"><span>here</span></a><span>. </span></span>

<span lang="EN-US"><span>Now you are ready to build your report and publish it to the Power BI Service. </span></span>

<span lang="EN-US"><span>If you want to keep your data updated on the Power BI Service you will need to use the </span></span><a href="https://powerbi.microsoft.com/en-us/gateway/"><span lang="EN-US"><span>Power BI Gateway</span></span></a><span lang="EN-US"><span>. </span><span> </span><span> </span></span>

<span lang="EN-US"><span>For using the Gateway you need to add the Data Source on the Mange Gateways menu. </span></span>
<p style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2017/04/42.png"><img width="651" height="586" class="alignnone size-full wp-image-2165" alt="4" src="https://msdnshared.blob.core.windows.net/media/2017/04/42.png" /></a><a href="https://msdnshared.blob.core.windows.net/media/2017/04/17.png"></a></p>
For the connection string use the same connection string as in the Power BI Desktop file:
<p style="padding-left: 30px">Driver={ODBC Driver 13 for SQL Server};Server=tcp: &lt;Server Name &gt; ,1433;Database= &lt;Database name&gt;;Encrypt=yes;TrustServerCertificate=no;Connection Timeout=30;Authentication=ActiveDirectoryPassword</p>
Now you will be able to select the gateway and perform the refresh.

&nbsp;

Beatriz García

<a href="https://twitter.com/beroces">@BeRoces</a>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Lesson Learned #25: Export/Import Azure SQL Database using Azure File Service?</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/lesson-learned-25-exportimport-azure-sql-database-using-azure-file-service</link>
      <pubDate>Mon, 03 Apr 2017 18:53:16 GMT</pubDate>
      <dc:creator><![CDATA[Jose M Jurado - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2125</guid>
      <description><![CDATA[In some situations, we need to import or export our Azure SQL Database using SQLPackage, but,...]]></description>
      <content:encoded><![CDATA[In some situations, we need to <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-import-sqlpackage">import </a>or <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export-sqlpackage">export</a> our Azure SQL Database using <a href="https://msdn.microsoft.com/es-es/library/hh550080(v=vs.103).aspx">SQLPackage</a>, but, unfortunately, either source and destination file we cannot specify a blob storage, in case that we want to save the file in this storage. For this reason, we have to use a local temporal folder for uploading/downloading the file depending on our needs.

However, we have an alternative, using <a href="https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-how-to-use-files">Azure File Services</a>. Once we have configured this we could use it as a local drive and use this for our <a href="https://msdn.microsoft.com/es-es/library/hh550080(v=vs.103).aspx">SQLPackage</a>.

For example, I create an <a href="https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-how-to-use-files">Azure File Storage</a> and I connect it using the following command:
<ul>
 	<li>net use f: \\myfile.file.core.windows.net\mysqlpackage /u:useraccount mykey</li>
 	<li>Once we have specified this network drive we could use sqlpackge, like this one to import our data. sqlpackage.exe /a:import /sf:f:\data.bacpac /tdn:mydb /tsn:myserver.database.windows.net /tp:password /tu:user</li>
</ul>
Enjoy!]]></content:encoded>
    </item>
    <item>
      <title>Exported database from Azure SQL failed to be imported to Azure SQL or to local SQL Server</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/exported-database-from-azure-sql-failed-to-be-imported-to-azure-sql-or-to-local-sql-server</link>
      <pubDate>Thu, 30 Mar 2017 14:46:59 GMT</pubDate>
      <dc:creator><![CDATA[Yochanan Rachamim - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2096</guid>
      <description><![CDATA[Symptoms: 

When using blob auditing on Azure SQL Server or Database, after you export database to...]]></description>
      <content:encoded><![CDATA[<strong>Symptoms: </strong>

When using blob <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-auditing">auditing </a>on Azure SQL Server or Database, after you <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export">export </a>database to .bacpac file

if you import the database to another Azure SQL DB that already have blob auditing enabled at the server level you may get this error message:
<p style="padding-left: 30px">Could not import package.
Error SQL72014: .Net SqlClient Data Provider: Msg 15578, Level 16, State 1, Line 1 There is already a master key in the database. Please drop it before performing this statement.
Error SQL72045: Script execution error. The executed script:
CREATE MASTER KEY;</p>
if you import the database to local on-premise SQL Server installation you may get this error:
<p style="padding-left: 30px">Error SQL72014: .Net SqlClient Data Provider: Msg 33161, Level 15, State 1, Line 1 Database master keys without password are not supported in this version of SQL Server.
Error SQL72045: Script execution error. The executed script:
CREATE MASTER KEY;</p>
this also apply if you created master key without password for your own usage.

<strong>Cause: </strong>

This caused by a different behavior between Azure SQL DB and Local SQL Server installation

a master key without password is an Azure SQL DB only feature, while local SQL Server installation must have password encryption for master key.

read more about it here <a href="https://docs.microsoft.com/en-us/sql/t-sql/statements/create-master-key-transact-sql">CREATE MASTER KEY (Transact-SQL)</a>

failure to import back to Azure SQL caused by a limitation in the import process.

our teams are currently working to change this behavior from the server side.

<strong>Resolution:</strong>
<h5><em>Option 1</em></h5>
to mitigate import to Azure SQL DB use the import from the Azure portal.

to mitigate import to local SQL Server installation you can alter the existing master key and add password encryption to it.

this should be done before you export the database
<blockquote>
<pre>ALTER MASTER KEY ADD ENCRYPTION BY PASSWORD = '&lt;PasswordHere&gt;';</pre>
</blockquote>
<h5>Option 2</h5>
for short term mitigation we provide you PowerShell script that do the following:
<ul>
 	<li>remove the master key object from the bacpac</li>
 	<li>remove the credential object from the bacpac</li>
</ul>
after running this PS script on the bacpac you will have new bacpac file with "patched" suffix.
<h4>download it <a href="https://github.com/yochananrachamim/AzureSQL/blob/master/RemoveMasterKeyFrombacpac.zip?raw=true">here</a></h4>
example:
<blockquote>
<pre>C:\PS&gt; .\RemoveMasterKey.ps1  -bacpacPath "C:\BacPacs\Test.bacpac"</pre>
</blockquote>]]></content:encoded>
    </item>
    <item>
      <title>Lesson Learned #24: How to read or import Azure SQL Auditing Blob file?</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/lesson-learned-24-how-to-read-or-import-azure-sql-auditing-blob-file</link>
      <pubDate>Tue, 21 Mar 2017 09:59:31 GMT</pubDate>
      <dc:creator><![CDATA[Jose M Jurado - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2075</guid>
      <description><![CDATA[As probably, you know we have two different types for Azure SQL Auditing : Table or Blob. For table...]]></description>
      <content:encoded><![CDATA[As probably, you know we have two different types for <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-auditing">Azure SQL Auditing</a> : Table or Blob. For table type we have several ways to read this <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-auditing">Excel</a>, <a href="https://powerbi.microsoft.com/en-us/documentation/powerbi-azure-sql-database-auditing-connector/">PowerBI</a>, etc..

In this post, we are going to talk about how to read or import the file generated by blob type. When we configured this type, the file generated has the extension XEL that means that will be an Extended Event file. So, you have the option to open the file directly using your SQL Server Management Studio and also, you have <a href="https://msdn.microsoft.com/en-us/library/cc280743.aspx">sys.fn_xe_file_target_read_file</a> function. For example, running this statement, SELECT CONVERT(XML,event_data) as xml, * FROM sys.fn_xe_file_target_read_file('https://xxxxxx.blob.core.windows.net/sqldbauditlogs/server/database/SqlDbAuditing_ServerAudit_NoRetention/2017-03-17/23_34_35_412_0.xel', null, null, null) I would be able to read all audit rows.

A very good advantage is that we are able to read the data directly from the blob storage without download to our local machine.

Enjoy it!]]></content:encoded>
    </item>
    <item>
      <title>Quickly test connectivity from Azure Website to SQL DB</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/quickly-test-connectivity-from-azure-website-to-sql-db</link>
      <pubDate>Tue, 14 Mar 2017 22:59:49 GMT</pubDate>
      <dc:creator><![CDATA[Vitor Faria Tomaz]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2045</guid>
      <description><![CDATA[In case you have an Azure Website and you need to confirm that your website can reach SQL Database...]]></description>
      <content:encoded><![CDATA[In case you have an Azure Website and you need to confirm that your website can reach SQL Database service here is a quick and simple way to test it:

1) navigate to <strong>Kudu</strong> (it can be accessed at https://{yourwebsitename}.<strong>scm</strong>.azurewebsites.net )

(Kudu is the engine behind git/hg deployments, WebJobs, and various other features in Azure Web Sites)

&nbsp;

2) open CMD that it’s located under ‘Debug console’ menu

&nbsp;

3) run <strong>tcpping</strong> against your server using: <strong>tcpping </strong>{servername}<strong>.database.windows.net:1433</strong>

&nbsp;

you will see something like this:

<a href="https://msdnshared.blob.core.windows.net/media/2017/03/Kudu_tcpping.png"><img src="https://msdnshared.blob.core.windows.net/media/2017/03/Kudu_tcpping.png" alt="kudu_tcpping" width="814" height="685" class="size-full wp-image-2056" /></a>

&nbsp;

If you don’t see <strong>successful attempts</strong> something is wrong, please open a new support request so we can help you.]]></content:encoded>
    </item>
    <item>
      <title>Lesson Learned #23: How to add AAD Security Groups to Azure SQL Database?</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/lesson-learned-23-how-to-add-aad-security-groups-to-azure-sql-database</link>
      <pubDate>Fri, 10 Mar 2017 18:18:34 GMT</pubDate>
      <dc:creator><![CDATA[Jose M Jurado - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=2035</guid>
      <description><![CDATA[In these days, we are receiving multiples cases where our customer needs to add Azure SQL Database...]]></description>
      <content:encoded><![CDATA[In these days, we are receiving multiples cases where our customer needs to add Azure SQL Database groups from Azure Active Directory.

This is an example to how to archive it.
<ul>
 	<li>Using the Portal in Azure:
<ul>
 	<li>I created a user called SQLMember.</li>
 	<li>I created a group called SQLGroup, adding the member SQLMember.</li>
</ul>
</li>
</ul>
&nbsp;
<ul>
 	<li>Using SQL SERVER Management Studio connected to the User Database using the Azure Active Directory Admin User and clicking New Query.
<ul>
 	<li>I create as user group of this database - CREATE USER [SQLGroup] FROM EXTERNAL PROVIDER - <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-manage-logins">https://docs.microsoft.com/en-us/azure/sql-database/sql-database-manage-logins</a></li>
</ul>
</li>
</ul>
&nbsp;
<ul>
 	<li>Running SELECT * FROM SYS.DATABASE_PRINCIPALS we could see that the group has been created in Azure SQL Database</li>
</ul>
&nbsp;
<ul>
 	<li>I executed the TSQL: EXEC sp_addrolemember 'db_datareader', 'SQLGroup' to give the permissions to this group just of read-only. - <a href="https://msdn.microsoft.com/en-us/library/ms187750.aspx">https://msdn.microsoft.com/en-us/library/ms187750.aspx</a></li>
</ul>
&nbsp;
<ul>
 	<li>Finally, I disconnected from SQL Server Management Studio and I connect again using the user SQLMember@mydomain.com to the database and I was able to connect without issue, applying the read-only permissions for the database</li>
</ul>]]></content:encoded>
    </item>
    <item>
      <title>Lesson Learned #22: How to identify blocking issues?</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/lesson-learned-22-how-to-identify-blocking-issues</link>
      <pubDate>Tue, 21 Feb 2017 20:22:52 GMT</pubDate>
      <dc:creator><![CDATA[Jose M Jurado - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=1995</guid>
      <description><![CDATA[Today, we were working on a service request where our customer reported that, some TRUNCATE...]]></description>
      <content:encoded><![CDATA[Today, we were working on a service request where our customer reported that, some TRUNCATE executions are taking more time that they expected. Normally, these TRUNCATE commands just only take 3 or 5 seconds to complete, however, this time, the problem is that they never finish.

Using the following TSQL command:
<p style="padding-left: 30px">select conn.session_id as blockerSession,conn2.session_id as BlockedSession,req.wait_time as Waiting_Time_ms,cast((req.wait_time/1000.) as decimal(18,2)) as Waiting_Time_secs,
cast((req.wait_time/1000./60.) as decimal(18,2)) as Waiting_Time_mins,t.text as BlockerQuery,t2.text as BlockedQuery, req.wait_type from sys.dm_exec_requests as req
inner join sys.dm_exec_connections as conn on req.blocking_session_id=conn.session_id
inner join sys.dm_exec_connections as conn2 on req.session_id=conn2.session_id
cross apply sys.dm_exec_sql_text(conn.most_recent_sql_handle) as t
cross apply sys.dm_exec_sql_text(conn2.most_recent_sql_handle) as t2</p>
&nbsp;

We identified that these TRUNCATE commands are waiting for another query that is reading the data/is hanging. Basically, killing the session using KILL TSQL command all those TRUNCATE commands were completed successfully.]]></content:encoded>
    </item>
    <item>
      <title>Automate Export Azure SQL DB to blob storage use Automation account</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/automate-export-azure-sql-db-to-blob-storage-use-automation-account</link>
      <pubDate>Tue, 07 Feb 2017 19:37:36 GMT</pubDate>
      <dc:creator><![CDATA[Mohamed Baioumy - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=1785</guid>
      <description><![CDATA[I had a support case recently question how to automate Export Azure SQL DB to a storage account...]]></description>
      <content:encoded><![CDATA[I had a support case recently question how to automate Export <strong>Azure SQL DB</strong> to a storage account (<em>Blob container)</em> to .bacpac files. The first attempt was made to configure a PowerShell Script to Export Azure SQL DB to blob container and to .bacpac format from <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-export-powershell">here </a>. this was successfully completed but on demand, the coming questions is. How we can run this PowerShell script into a scheduled job?, as you all know Azure SQL DB have no SQL Agent in place. One way to do this either from client side or using Azure VM to schedule run PowerShell script!

That`s fine, but what if you can do this from Azure Portal, Yes! , you can do this! using Automation account runbooks feature. With no dependency on client or Azure VM schedule task to execute PowerShell export script for you!

I`ve searched for a complete document can demonstrate how to achieve this. Unfortunately, I did not find any. So In this blog, we will walk through how to accomplish this step-by-step,

&nbsp;

<strong>PREREQUISITES</strong>
To complete this exercise, you should have following resources in place:
1) Azure SQL Server and DB, for more reference how to create Azure SQL DB, Server from <a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-get-started">here</a>
2) Storage account created and configured include blob container for remote backup SQL DB. For more reference how to create new storage account and associated blob container from <a href="https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account">here</a>

&nbsp;

<strong>STEPS</strong>
1) Go to <a href="https://portal.azure.com/">https://portal.azure.com/</a>
2) From More services in the bottom on the left hand search for <strong>"Automation Accounts"</strong>, select, this will open Automation account blade
3) Click <strong>Add</strong> to create a new Automation account, type in Name field: “<em>MyAutomationAccount</em>” or as you like to name your Automation account, select desired subscription if you register more than one subscription. (make sure all resources (<em>SQL DB, Server, storage account</em>) existing in the same subscription as you creating automation account). Use or create a new Resource group.

Leave Create Azure Run As account as default (Yes).
4) First, Make sure “<em>AzureClassicRunAsConnection</em>” and “<em>AzureRunAsConnection</em>” <strong>connections</strong> created automatically during Automation account creation. Note: (“<em>AzureRunAsConnection</em>” connection will be used in our PowerShell workflow script later to authenticate to Azure subscription)
5) Second, Verify that your Automation account has latest <strong>modules</strong> imported and are up to date (AzureRM.Automation - AzureRM.Profile - AzureRM.Sql) to Version: <strong>2.5.0</strong>
6) If modules show a different version, <strong>i.e. 1.0.3</strong> select modules show old version and Import to update to version 2.5.0
7) Third, Import PowerShell script <span style="text-decoration: underline">Update-ModulesInAutomationToLatestVersion</span> from runbook gallery and make sure it is published (<strong>without this PowerShell script the Export PowerShell workflow will not work</strong>)

&nbsp;

To import <span style="text-decoration: underline">Update-ModulesInAutomationToLatestVersion</span> PowerShell script from runbook Gallery, follow below steps:
a. Go to automation account
b. Select runbooks from middle blade
c. From top bar select “<strong>Browse gallery</strong>”
d. Set the filter “<strong>Gallery Source</strong>” to “<strong>PowerShell Gallery</strong>”
e. Search for <span style="text-decoration: underline">Update-ModulesInAutomationToLatestVersion</span> PowerShell script
f. Select this script and import it
g. Revert to runbooks again
h. Select recently imported PowerShell script
i. From top bar select <strong>Edit</strong>, then <strong>Publish</strong>
j. Verify that this script in <strong>Published</strong> state

&nbsp;

<strong>Now we will import the PowerShell workflow script!</strong>
1) From Automation account overview dashboard
2) Select runbooks
3) Click <strong>Add a runbook</strong> (make sure you select PowerShell Workflow from category not PowerShell!)
4) Select Import an existing runbook and select to add <strong>ExportAzureDB-PowerShellWorkflow</strong> (PowerShell script code below)
5) Once new runbook created, it will present in runbooks in new state!
6) Select <strong>ExportAzureDB-PowerShellWorkflow</strong> and from top bar click <strong>Edit</strong>,
7) Update required parameters match your environment and <strong>Save</strong>, then <strong>Test pane</strong> to start run this runbook to test result before set to Publish
8) Once <strong>Test pane</strong> completed, click <strong>Published</strong>, then you can assign a schedule for this runbook per your preference
9) Review storage blob container for successfully exported .bacpac file
10) You can review completed jobs from runbooks jobs

&nbsp;

<strong>PowerShell script (copy and save as .ps1)</strong>

&lt;#

.SYNOPSIS Export Azure SQL DB to blob storage in .bacpac format

.DESCRIPTION This runbook export Azure SQL DB to blob storage container use below parameters.

.PARAMETER DatabaseName

Name of the database

.PARAMETER ServerName

Name of the SqlServer

.PARAMETER ServerAdmin

Name of server admin login name

.PARAMETER ResourceGroupName

name of resource group contains the SqlServer and DatabaseName

.PARAMETER ServerPassword

Password for sql server admin login

.PARAMETER BaseStorageUri

full uri for storage account name include container name https://STORAGE-NAME.blob.core.windows.net/BLOB-CONTAINER-NAME/

.PARAMETER StorageKey

storage account access key "YOUR STORAGE KEY" go to storage account --&gt; settings --&gt; select Access Keys --&gt; Copy/Paste key1

.NOTES
This script provided AS IS, Please review the code before executing this on production environment
For any issue or suggestion please email to: mobaioum@microsoft.com

#&gt;
# ---- Login to Azure ----
workflow ExportAzureDB-PowerShellWorkflowScript {
inlineScript {
$connectionName = "AzureRunAsConnection"
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName

"Login to Azure"
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
}
catch {
if (!$servicePrincipalConnection)
{
$ErrorMessage = "Connection $connectionName not found."
throw $ErrorMessage
} else{
Write-Error -Message $_.Exception
throw $_.Exception
}
}

# Database to export
$DatabaseName = "hidden"
$ServerName = "hidden"
$ServerAdmin = "hidden"
$ResourceGroupName = "hidden"
$serverPassword = "hidden"
$securePassword = ConvertTo-SecureString -String $serverPassword -AsPlainText -Force
$creds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $serverAdmin, $securePassword

# Generate a unique filename for the BACPAC
$bacpacFilename = $DatabaseName + (Get-Date).ToString("yyyy-MM-dd-HH-mm") + ".bacpac"

# Storage account info for the BACPAC
$BaseStorageUri = "https://STORAGE-NAME.blob.core.windows.net/BLOB-CONTAINER-NAME/"
$BacpacUri = $BaseStorageUri + "/Daily/" + $bacpacFilename
$StorageKeytype = "StorageAccessKey"
$StorageKey = "YOUR STORAGE KEY"

$exportRequest = New-AzureRmSqlDatabaseExport -ResourceGroupName $ResourceGroupName -ServerName $ServerName `
-DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri `
-AdministratorLogin $creds.UserName -AdministratorLoginPassword $creds.Password

# Check status of the export
$exportStatus = Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink

Write-Output "Azure SQL DB Export Completed at $DatabaseName"

}
}

&nbsp;

<strong>Enjoy automated export SQL DB!</strong>

&nbsp;]]></content:encoded>
    </item>
    <item>
      <title>Lesson Learned #21: There is not enough space on the disk exporting BacPac using SSMS</title>
      <link>https://docs.microsoft.com/archive/blogs/azuresqlemea/lesson-learned-21-there-is-not-enough-space-on-the-disk-exporting-bacpac-using-ssms</link>
      <pubDate>Thu, 02 Feb 2017 13:03:39 GMT</pubDate>
      <dc:creator><![CDATA[Jose M Jurado - MSFT]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/azuresqlemea/?p=1755</guid>
      <description><![CDATA[Depending on the size of your database when you export/import the data to/from a bacpac using SQL...]]></description>
      <content:encoded><![CDATA[Depending on the size of your database when you export/import the data to/from a bacpac using SQL SERVER Management Studio you could see an error like this one: <strong>There is not enough space on the disk</strong>, however, the destination/source of the data file has a lot of free space.

This issue is caused by the temporary files that SQL Server Management Studio is creating to compress/decompress the data in your %temp% folder to export/import the data to/from bacpac.

More insights of this issue:
<ul>
 	<li>As you know bacpac file is, at the end, a zip file. For example, if you change the extension from bacpac to zip, you would be able to see the contents.</li>
 	<li>For every table, SSMS needs to create in a temporal file.</li>
 	<li>If we are exporting the data, at the final stage, SSMS needs to compress the data in a bacpac file.</li>
 	<li>If we are importing the data, at the first stage, SSMS needs to uncompress the dataase from a bacpac file.</li>
 	<li>Using <a href="https://technet.microsoft.com/en-us/sysinternals/processmonitor.aspx">ProcMon </a>I saw multiple files created in the %temp% or %tmp% local folders. Some of them, are hidden, so, we need to enable to see those files. For example, I saw a file created by SSMS process and extension .model that there is a file of the bacpac contents.</li>
</ul>
<p style="padding-left: 60px"><a href="https://msdnshared.blob.core.windows.net/media/2017/02/bacpacOutOfSpace.png"><img width="300" height="202" class="alignnone size-medium wp-image-1765" alt="bacpacoutofspace" src="https://msdnshared.blob.core.windows.net/media/2017/02/bacpacOutOfSpace-300x202.png" /></a></p>

<ul>
 	<li>Changing the %temp% or %tmp% environment variables, pointing to a drive with enough capacity this issue was solved.</li>
</ul>]]></content:encoded>
    </item>
  </channel>
</rss>