We have previously specified how Azure Synapse Artifacts deployment can be achieved using FlexDeploy in this article. In the current article we are going to elaborate more on how to implement package-based deployment for the same.
Design
There are two approaches we follow here:
Approach A:
Configuring a Generic Package based project, create and deploy the ARM templates being generated based on those specific resources.
Approach B:
First Phase - Configuring a Generic Package based project, create the ARM template based on the specific resources and store it in a repository. This repository may contain all the ARM templates corresponding to different packages. Will showcase it later in this tutorial.
Second Phase - Configuring another package-based project that will fetching the ARM template from the repository and initiate the Synapse Release pipeline.
The benefit of the second approach is there would be more control over the ARM template which can be edited as needed by adding a new parameter or variables or something else.
Create a Project by choosing the Classification: Package-based and Project Types as Generic
Once it is created the Source Control needs to be configured, so that we can discover the files from the respective repository.
For example, this is how the repository looks like where we have all the artifacts uploaded from Synapse Dev Workspace.
Discover the files using File Catalog tab
Now we can create Package upon selecting specific files for which the ARM template should get generated and the specific resources would be deployed to the Target Synapse Workspace.
Say we have two pipelines in repository but want to deploy only one to the target workspace, in that case we can create a package and add the pipeline file in it.
Click on the Configuration tab, select General and update the Build and Deploy workflows along with respective Target groups.
Execution
Initiate Build on the selected Package “pipeline”.
Note: The ARM templates are published to Azure DevOps Feed as Artifacts with the package name as a keyword in it. Example: if the FD project name is SynapseOrchestration-Incremental and the package name is “pipeline” then the artifacts package name would be “pipeline-synapseorchestration-incremental-armtemplate“. Now Microsoft has certain restrictions on the naming of the Azure Artifacts, hence please follow the guide before you name the package that you create in FD or else adjust your workflow to be in compliance. Restrictions and conventions for naming objects - Azure DevOps
To verify, clicked on the Artifacts tab and verified the ARM template and it shows up with just one selected pipeline.
Now initiated the Deploy.
Flow (Approach B)
Workflow configuration for creating ARM template and upload to Repository
Build Workflow:
Note: For uploading the ARM template to repository, we have created another DevOps repository as az-synapse-arm and configured it in FlexDeploy-Integration with the code SYNAPSEARM.
If you have some other repository present in GITHUB or Azure DevOps anywhere and want to use that, then please create accordingly and use the correct Instance Code in the workflow pasted below.
Create a Project by choosing the Classification: Package-based and Project Types as Generic
Once it is created the Source Control needs to be configured, so that we can discover the files from the respective repository.
For example, this is how the repository looks like where we have all the artifacts uploaded from Synapse Dev Workspace.
Discover the files using File Catalog tab
Now we can create Package upon selecting specific files for which the ARM template should get generated and the specific resources would be deployed to the Target Synapse Workspace.
Say we want to selectively migrate the linkedservice AzureBlobStorageDemo to the target workspace, in that case we can create a package linkedservice and add it in.
Click on the Configuration tab, select General and update the Build workflow with respective Target groups.
We are not configuring any Deploy workflow in this Project for the purpose of this Tutorial, as all we need is to create the ARM template and upload it to GIT.
Execution
Initiate Build on the selected Package “linkedservice”.
Note: The ARM templates are published to Azure DevOps Feed as Artifacts with the package name as a keyword in it. Example: if the FD project name is ExtractSynapseArtifacts and the package name is “linkedservice” then the artifacts package name would be “linkedservice-extractsynapseartifacts-armtemplate“. Now Microsoft has certain restrictions on the naming of the Azure Artifacts, hence please follow the guide before you name the package that you create in FD or else adjust your workflow to be in compliance. Restrictions and conventions for naming objects - Azure DevOps
To verify, clicked on the Artifacts tab and verified the ARM template and it shows up with just one selected pipeline.
The ARM template is now uploaded to repository
The folder name is following the naming we selected for the package name in FD for right control. If any parameter is to be added/updated or some other manipulation is to be done in the ARM template json in terms of variables or parameters, it can be done. But the integrity of the json file should remain intact.
Workflow configuration for fetching the ARM template from the repository and initiate the Synapse Release pipeline
Build Workflow:
Deploy Workflow:
Project Configuration
Create a Project by choosing the Classification: Package-based and Project Types as Generic
Once it is created the Source Control needs to be configured, so that we can discover the files from the respective repository. This time the source control is the one where we have uploaded the ARM template.
Discover the files using File Catalog tab
Now we can create Package upon selecting specific ARM template that to be deployed to the Target Synapse Workspace.
Click on the Configuration tab, select General and update the Build and Deploy workflows with respective Target groups.
Parameterizing the values
Replacement configuration on Project
Starting 7.0 we have a new feature that allows us to replace a string in any file with another string based on as it is executed to different environment. Ref: Replacements
For our use-case a specific parameter as below is created in the Linked Service:
Our objective is that when this linked service gets deployed to target cicd-demo-uat workspace, the value would get replaced with “UAT”.
In the ARM template that we stored in repository, it shows up like this:
Using Environment Variables for the parameters
Say the linked service we are using is having the connection params in the source workspace as the following:
The parameter file in ARM template folder looks like:
If the value for the Storage Account is to be changed then the parameter needs to be passed in AzureBlobStorageDemo_connectionString.
Hence, we can configure the below connection string with the parameter name in the Target Group properties for the code: ENVIRONMENT_VARIABLES_LIST.
Anything that is specified as parameter in the ARM templates, can be parameterized like above during deployment to Target Workspace
Execution
Initiate Build on the selected Package “linkedservice”.
To verify, clicked on the Artifacts tab and verified the ARM template.
Click on Deploy for the same
Post deployment if we verify the Linked Service in UAT workspace, we see the updated values in there:
The following macros are not currently supported in the footer: