How to Deploy Linked service with dynamic names to other enviornemnts

Firthouse M G 80 Reputation points
2025-04-21T14:39:05.0733333+00:00

Hi Microsoft support team - Am writing you to get the best answer for handling the Linked service name while deploying Azure Data Factory ARM template to the higher environments.

In DEV I have linked service names like ABC_DEV_DB, DEF_DEV_DB.

While moving this code to the QA I want to replace them as ABC_QA_DB, DEF_QA_DB and for UAT,TEST,PROD accordingly based on environment. How to achieve this. We will develop in DEV environment and use that same template to do deployment in higher environments.

Thanks.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,639 questions
{count} votes

Accepted answer
  1. Sina Salam 22,031 Reputation points Volunteer Moderator
    2025-04-22T01:02:24.18+00:00

    Hello Firthouse M G,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.

    I understand that you want to deploy Azure Data Factory ARM templates to higher environments (QA, UAT, TEST, PROD) with dynamic linked service names based on the environment. Linked service names in DEV should be ABC_DEV_DB, DEF_DEV_DB, and you want them to be ABC_QA_DB, DEF_QA_DB in QA, and similarly for other environments.

    This is a step by step that you can follow:

    // Define Parameters in ARM Template:
       "parameters": {
           "linkedServiceName": {
               "type": "string"
           }
       }
    
    // Use Parameter in Linked Service Definition
       "resources": [
           {
               "type": "Microsoft.DataFactory/factories/linkedServices",
               "name": "[parameters('linkedServiceName')]",
               ...
           }
       ]
    
    // Create Parameter Files for Each Environment**:
       // - `parameters-dev.json`:
     
         {
             "linkedServiceName": {
                 "value": "ABC_DEV_DB"
             }
         }
    
       // - `parameters-qa.json`:
      
         {
             "linkedServiceName": {
                 "value": "ABC_QA_DB"
             }
         }
    
    

    Finally, deploy ARM Template Using Azure CLI using bash command:

    az deployment group create --resource-group <ResourceGroupName> --template-file <ARMTemplateFile> --parameters @parameters-dev.json
    

    This method is efficient, reduces manual errors, and aligns with best practices for ARM template deployment, you can read more on https://learn.microsoft.com/en-us/azure/data-factory/deploy-linked-arm-templates-with-vsts and https://learn.microsoft.com/en-us/azure/data-factory/continuous-integration-delivery-linked-templates and https://learn.microsoft.com/en-us/azure/azure-resource-manager/templates/best-practices

    I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.


    Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.


1 additional answer

Sort by: Most helpful
  1. Luis Arias 8,621 Reputation points Volunteer Moderator
    2025-04-21T21:07:23.37+00:00

    Hi Firthouse,

    Welcome to Q&A, there are many ways to approach what you need it . The simplest way I can suggest to handle linked service names dynamically while deploying Azure Data Factory ARM templates to different environments:

    • Start by making your ARM template flexible. Instead of hardcoding the linked service names, use a parameter to define them. In your template, you can set up a parameter like this:
    "parameters": {
        "linkedServiceName": {
            "type": "string"
        }
    }
    
    • Then, use this parameter in the linked service definition within your template. This way, you can pass the environment-specific name during deployment. For example, you might reference it in your resource section like this:
    "type": "Microsoft.DataFactory/factories/linkedServices",
    "name": "[parameters('linkedServiceName')]"
    
    • Next, create separate parameter files for each environment, such as DEV, QA, UAT, TEST, and PROD. In these files, set the linkedServiceName value specific to the environment. For instance: In parameters-dev.json, define the name as ABC_DEV_DB. In parameters-qa.json, use ABC_QA_DB, and so on for other environments.
    • When you're ready to deploy the ARM template to a particular environment, use the corresponding parameter file to set the linked service name. You can do this with Azure CLI or PowerShell. Here's an example using Azure CLI:
    az deployment group create --resource-group <ResourceGroupName> --template-file <ARMTemplateFile> --parameters @parameters-dev.json
    

    If the information helped address your question, please Accept the answer.

    Luis

    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.