Make SQL databases go automatically into elastic pools - sql-server

I'm having some trouble using Azure's elastic pool feature. Right now, I have a SQL server with a bunch of databases that I want to store in an elastic pool to cut costs. My problem is that right now, everything is deployed in a very specific, non-negotiable way. Resource groups, storage accounts, and SQL servers are spun up with ARM templates and databases are added to the server with Microsoft's Azure SQL Database Deployment function in VSTS. Everything I do should be automated for disaster recovery.
Is there a way to configure the server on creation so everything goes automatically into the elastic pool? Is there a way to change the Azure SQL Database Deployment step so it adds the db to the pool and not just the server?
Thanks in advance.
Edit: I ended up adding a powershell task to VSTS and running a simple json+script that took in the resource group, server name, pool name, and database names, then ran Set-AzureRmSqlDatabase.

You can manage SQL Database elastic pools using PowerShell (e.g. Set-AzureRmSqlDatabase: Sets properties for a database, or moves an existing database into, out of, or between elastic pools.), so you can try to use Azure PowerShell step/task to move database to elastic pool.
Regarding ARM template, you can get it when creating SQL Database in azure portal:
On the other hand, there is an article about a template allows to deploy a new SQL Elastic Pool with its new associated SQL Server and new SQL Databases to assign to it: Deploy a new SQL Elastic Pool

I solved it with a custom build step. Included the required parameters in a json and ran a powershell script that connected with
Initialize-AzurePowershellSupport -ConnectedServiceName $ConnectedServiceName -ErrorAction SilentlyContinue
$subscription = (Get-AzureRmContext).Subscription.SubscriptionName #(Get-AzureRmContext).Subscription.SubscriptionName
and then used Set-AzureRmSqlDatabaseto move the database to an elastic pool.

Related

How to connect to an on-premises SQL Server from an Azure ML notebook?

I typically use pyodbc when running jupyter notebooks from my machine, but this does not work on Azure ML. My assumption is that this is being caused by Azure ML not knowing if I'm on my company's network as I typically need a VPN to the server if I'm not in office. The only solutions I can find online involve copying the data over on Azure Data Factory however I need to avoid this if possible as there are many tables I will need to experiment with, but nothing is intended to be long term and I'm unsure what I will even end up using.
Ideally there is a way to make pyodbc work but any other suggestions are welcome. I have researched integration runtimes but was unsure if that would solve my problem here.
The only solutions I can find online involve copying the data over on
Azure Data Factory however I need to avoid this if possible as there
are many tables I will need to experiment with, but nothing is
intended to be long term and I’m unsure what I will even end up using.
Ideally there is a way to make pyodbc work but any other suggestions
Unfortunately, the on-Prem SQL Server is not supported as a Data Source in Azure ML.
Only the Data sources available below are supported:-
Approach1)
You can copy your data from the on-premises SQL database to Azure SQL via copy tool in Azure Data factory and connect to Azure SQL via Azure Machine learning by directly connecting to it via Datasource like below:-
You can also use Self-hosted integration run time to connect to your SQL server on-prem in your data factory:-
Click on Option 2 to download the Integration runtime and set it in your local machine with the Registration keys mentioned above:-
Approach2)
If there’s a large data You can automate your entire copy process from the on-prem SQL server to Azure SQL by using the Azure DevOps pipeline.
References:-
https://learn.microsoft.com/en-us/answers/questions/775844/unable-to-connect-sql-server-to-azure-ml-pipeline By Ramr-msft
How To: Azure Data Factory CI/CD with Azure DevOps pipelines — The YAML WAY! | by Raghavendra Bharadwaj | Servian

Continous deployments for on prem databases with Azure DevOps

Everyone, I'm looking on a way to deploy updates to our on prem databases using Azure DevOps and I'm running into a roadblock on the release definition. I have my DACPAC ready to go, but not sure how to get that over to my on prem server.
I see the WinRM-SQL Server DB Deployment as a task, but not sure how to set that up. I have seen a couple of videos that use the SQL Server Database Deploy as an option, but it looks like that task has been deprecated, so it looks like I will need to use the WinRM-SQL task. So, could anyone point me in the right direction on how to set this task up to use my local SQL server or possibly a tutorial that help get me started?
You will also have to install a release agent on the target server where you will be deploying the database, assign it to a Deployment Group, create your release pipeline template and then run a release. I wrote a blog post about how to deploy a database to an on-prem SQL Server by leveraging Azure DevOps: https://jpvelasco.com/deploying-a-sql-server-database-onto-an-on-prem-server-using-azure-devops/
Hope this helps.
If you already created a Deployment Group, within your Pipeline:
Click to Add a new stage: [1]: https://i.stack.imgur.com/vc5TI.png
On the right side, (SELECT A TEMPLATE screen) type SQL in the search box
Select: IIS website and SQL database deployment, this will add a Stage with Two tasks: IIS deployment and SQL DB Deploy.
Delete the IIS Deployment Task
Configure the SQL DB Deploy task - It does not say it is deprecated.

SQL Server - Migrate Agent Jobs to Azure

We're in the final phase of migrating our SQL Server on VM to Azure SQL Server. What is the most time-efficient approach to getting our existing SQL Server Agent Jobs out to Azure? I've noticed that inside of SSMS, when connected to an Azure SQL Server, the Agent does not exist - we were aware of this before migrating, but I have yet to have found whether there is an Azure service that replaces the SQL Server Agent Jobs functionality.
There are a number of options.
If you need timed execution of some data momement, Azure Data Factory can be a good replacement.
There is also an Azure Scheduler, that is often mentioned as an alternative. However, I believe that would work better on API's than directly on a database.
I think the best option is Azure automation and create a runbook that connects to your database and performs some action.
An interesting blog that details these options in more detail can be foond at: https://blogs.technet.microsoft.com/uktechnet/2016/02/05/is-sql-server-agent-missing-from-azure-sql-database/

Azure SQL database failover

We are looking at setting up a high availability solution for a web application using Azure.
Azure SQL database has the Geo-Replication options to sync data to secondary copies of the database in a separate region.
If there is a failure in the primary region does the Azure SQL database automatically fail over to the secondary or is this something that has to be
done manually or by a custom monitoring tool not provided by Azure?
Thanks for your help
Gavin
It is provided by Azure automatically
Reference:
https://azure.microsoft.com/en-us/blog/fault-tolerance-in-windows-azure-sql-database/

Azure Virtual Machine and Azure SQL Database: optimal deployment for performance

The solution consists of an SQL Database and desktop application working hard with that DB. DB Deployed as Azure SQL Database, application running on Azure Virtual Machine with Windows Server onboard. What is the deployment guidelines for this two services in Azure? I want to achieve max performance. Should they both be located in same resource group?
You will need to get your app and the database located as close as possible so yes the same resource group.
Make sure you do not have Mars enabled (MultipleActiveResultSets in connection string).
Make sure you do use connection pooling.
Read this to understand what you are dealing with:
https://www.simple-talk.com/sql/learn-sql-server/improving-the-quality-of-sql-server-database-connections-in-the-cloud/
Ed

Resources