Serverless db creation using ci cd in synapse.

NAGA SANDEEP KUMAR KAPA 51 Reputation points
2022-08-16T13:27:30.857+00:00

Hi ,

I have synapse workspace already available. And I want to create one serverless db and run some scripts , stored procedure using ci/cd azure devops , without running it manually as we don't get access for higher environments. How to achieve this.

Thanks in advance.

Regards,
Sandeep

Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Bhargava-MSFT 31,261 Reputation points Microsoft Employee Moderator
    2022-08-21T04:38:49.123+00:00

    Hello @NAGA SANDEEP KUMAR KAPA ,

    Please follow the below steps for the serverless DB creation using CICD in the synapse.

    Release Pipeline contains the Azure Synapse Workspace Deployment task which is followed by a PowerShell task responsible to deploy the Serverless SQL Objects. The PowerShell Script can deploy/migrate the following SQL Objects- Database, Database Master Key Encryption, Database Scoped Credential, Schema, External Data Sources, External File Formats, External Tables, Views, and Stored Procedures.

    Prerequisites:

    1. Azure Synapse Analytics Workspace to be created in the target environment to which Serverless SQL Pool is to be deployed.
    2. GIT Configuration to be enabled for the Azure Synapse Analytics Workspace in the current environment by configuring the Azure DevOps Organization, Project, Repository, and the Root Folder. This facilitates the check-in to the Repos (Continuous Integration) for all the SQL objects to be migrated and deployed in the target environment.
      Note- Make sure to include 'GO' at the end of every SQL Script committed to the Repos.
    3. After configuring GIT and checking in the required SQL objects, publish the changes through the main branch in the Synapse Studio. This will generate the following ARM Template Files in the Publish Branch (default- workspace_publish) which will be used for Synapse Workspace Deployment in the Release Pipeline-

    o TemplateForWorkspace.json and
    o TemplateParametersForWorkspace.json

    1. Grant the Synapse Administrator Role to the Service Principal being used to deploy the Synapse Workspace through DevOps CD Pipeline.
    2. Install the “Synapse Workspace Deployment” extension from the Visual Studio Marketplace in the Organizational Settings.
    3. This article uses Access Token Authentication to connect to the Azure Synapse Serverless SQL Pool while deploying the SQL Objects. Create the following secrets in the Azure Key Vault which can be fetched from a Variable Group linked to the Release Pipeline-

    o Client ID
    o Tenant ID
    o Client Secret

    1. Similarly add the “SynapseDatabaseMasterKeyEncryptionKeyPassword” as an Azure Key Vault Secret which will be used to create the master key encryption for Serverless SQL Database.

    Azure Synapse Serverless SQL Continuous Deployment/ Release Pipeline:

    a) After the Synapse Workspace GIT Configuration, verify the repository folder structure as shown-

    233127-image.png

    b) Add the PowerShell Script under the synapse folder as shown-

    233136-image.png

    c) Create a New Release Pipeline with an empty job.

    d) Link the following artifacts to the release pipeline:

    1. SynapsePublishArtifacts

    233128-image.png

    2.SynapseSQLObjectsArtifacts

    233137-image.png

    e) Create and link the Variable Groups to the Release Pipeline with appropriate values for the variables– Resource Group, Synapse Workspace, SQL Server Instance, SQL Database, Database Schema, Database Scoped Credential, Master Key Encryption Password, ClientID, TenantID, and Client Secret.

    233156-image.png

    F) In the Release Pipeline Stages, add the Synapse Workspace Deployment task to deploy the Synapse Workspace.

    233211-image.png

    Note: Pay attention to the “Delete Artifacts Not in Template”- if enabled this will delete any artifacts from the previous releases not present in the current release publish artifacts.

    g) Now add the PowerShell task to deploy the Synapse Serverless SQL Objects to the Synapse Workspace.

    233129-image.png

    h) Create the pipeline release to verify the Synapse Serverless SQL Deployment.

    233221-image.png

    I have attached the executeSqlscripts in txt format. please use it in .ps1 format

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

    233782-executesqlscripts.txt

    1 person found this answer helpful.

  2. Lorenz Bangerter 0 Reputation points
    2024-02-08T16:37:45.71+00:00

    We want to use this approach to deploy and run sql scripts which create views in a serverless slq pool based on delta tables in a adls gen 2 storage account. We are using different storage accounts for dev and prd environment. Is there a way to dynamically change the storage account where the sql scripts creates the views from during deployment?

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.