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: (Recommended)
First Phase - Configuring a Generic Package based project. Select the JSON objects (say Linked Services, Pipeline etc.), generate the ARM template based on the selected 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 as specified in previous phase and initiate the Synapse Release pipeline to deploy them to target workspaces.
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 etc.
Approach B:
Configuring a Generic Package based project. Select the JSON objects (say Linked Services, Pipeline etc.), generate the ARM template based on the selected resources and deploy the ARM template to target workspaces. In this case the customization on parameters needs to be directly done on the JSON files by the user.
Flow (Approach A)
Workflow configuration for generating 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 source control looks like:
Discover the files using File Catalog tab
Now we can create Package upon selecting specific JSON files.
Click on the Configuration tab, select General and update the Build workflow with respective Target group.
We are not configuring any Deploy workflow in this Project for the purpose of this Tutorial, as all we need is to generate the ARM template and upload it to GIT.
Project properties
Follow this link to know about the Azure DevOps Build Pipeline configuration. This must be configured prior to configuring the FlexDeploy workflows and project properties.
Execution
Initiate Build on the selected Package.
Note: The ARM templates are published to Azure DevOps Feed as Artifacts with the package name as a keyword in it. Example: <packagename>-<fdprojectname>-json & <packagename>-<fdprojectname>-arm. 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
The ARM template is now uploaded to repository
The folder name is following the naming we selected for the package name in FD. 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 ARM template should remain intact.
Workflow configuration for fetching the ARM template from the repository and initiate the Synapse Release pipeline
Build Workflow:
description: SynapsePackageBuildARM
steps:
- id: '1'
name: Execute
type: INVOKE_PLUGIN
data:
pluginName: FlexagonShellPlugin
pluginOperation: execute
inputs:
- name: FDSHELL_INP_CODE_SNIPPET
value:
value: "# Define the name of the zip file to be created\r\nZIP_NAME=$FD_PROJECT_NAME.zip\r\n\r\nmkdir -p $FD_TEMP_DIR/ARMTEMPLATES\r\nfind $FD_TEMP_DIR -type f -name \"Template*.json\" -exec cp {} $FD_TEMP_DIR/ARMTEMPLATES \\;\r\ncd $FD_TEMP_DIR/ARMTEMPLATES\r\n\r\n# Find and zip all Template*.json files into a single zip file\r\nzip \"$ZIP_NAME\" *\r\ncp $FD_TEMP_DIR/ARMTEMPLATES/$ZIP_NAME $FD_ARTIFACTS_DIR\r\n\r\necho \"Zip created and moved to artifacts.\"\r\n"
isExpression: false
isEncrypted: false
- name: FDSHELL_INP_STOP_ON_ERROR
value:
value: 'false'
isExpression: false
isEncrypted: false
- name: FDSHELL_INP_DISABLE_ECHO
value:
value: 'false'
isExpression: false
isEncrypted: false
- name: FDSHELL_INP_RESTRICT_ENVIRONMENT
value:
isExpression: false
isEncrypted: false
- name: FDSHELL_INP_NO_SECURE_VARIABLES
value:
value: 'false'
isExpression: false
isEncrypted: false
- name: FDSHELL_INP_LOCK
value:
isExpression: false
isEncrypted: false
endpointInstanceOverride:
isExpression: false
consumesArtifacts: false
producesArtifacts: true
endpointSelection:
choice: All
endpointExecution:
choice: Any
stopOnError: false
outputs: []
userInputs: []
userOutputs: []
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 which is 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 group.
Parameterizing the values
There are many ways to do environment specific parameter value customization. 1) Using Replacement configuration of Project 2) Specifying the parameter as ${{}} in the source json file itself or the generated ARM template 3) Edit the generated ARM template to include the parameter as ARM template parameter. We will show option 2 in the following example.
For our use-case a specific parameter as below is created in the Linked Service:
When this source workspace is integrated with GIT, the linked service json file gets auto-synced there. One can edit the parameter manually to hold the target group property as
Once this is done as shown earlier, the target group property will take care of replacing it with right environment specific value during deployment.
Target Group configuration
Build = for build execution; UAT = for deploy execution.
Build
UAT
The Environment Specific Variables field controls the target workspace name and several other environment specific parameters. To know more follow this link.
Follow this link to know about the Azure DevOps Release Pipeline configuration. This must be configured prior to configuring the FlexDeploy workflows and project properties.
Execution
Initiate Build on the selected Package. Once done initiate the Deploy. Build produces the ARM templates as a zip bundle, which Deploy further passes on to the Azure DevOps Release Pipeline to deploy to target workspace.
The Output tab of createRelease step would show the Azue DevOps Release URL to further see the log in more detail:
Â
Post deployment if we verify the Linked Service in UAT workspace, we see the updated values in there.
Create a Project say SelectiveJsonDeployment, 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.
Note: These files are from the GIT integrated workspace that we use in Synapse for DEV environment.
For example, this is how the source control in Project looks like:
Project Properties
Â
Discover the files using File Catalog tab
Now we can create Package upon selecting specific files.
For example, here we chose two pipelines and a linked service to form the package called abstractdemo.
Click on the Configuration tab, select General and map the Build and Deploy workflows along with respective Target group.
Target Group configuration
Build = for build execution; UAT = for deploy execution.
Build
UAT
The Environment Specific Variables field controls the target workspace name and several other environment specific parameters. To know more follow this link.
Execution
Initiate Build on the selected Package abstractdemo.
It creates the artifacts with the zip bundle of json files.
Initiate Deploy on the built version.
Clicking on the createRelease step’s Output tab, you would find the release url of Azure DevOps Release pipeline. Navigating to that shows more log:
The following macros are not currently supported in the footer: