Categories: Azure Data Factory

Parameterize Linked Service in ADF with no Dynamic Content available

When you create linked services in Azure Data Factory (ADF) or in a Synapse Workspace, you typically want to parameterize certain properties of the connection. When you deploy your artefacts to another environment, you can change the parameter values to switch the connection to the new environment. For example, the server name of the connection pointing to your data warehouse is (hopefully) different between your development and production environment. During deployment, you change the server name from the dev environment to the server name of the production environment. You don’t want your production jobs accidentally updating your development environment.

You can parameterize linked services by adding “dynamic content”, which is ADF-speak for parameterizing a property. In the following screenshot, you can see the server name has been parameterized using a parameter with the (obvious) name server. When you deploy ADF/Synapse workspace, you can then change the default value of this parameter between environments.

However, in some linked services some properties don’t have the ability to use dynamic content. For example, the Microsoft 365 linked service doesn’t support parameterizing the service principal ID that is used to connect to the Microsoft 365 Graph.

It’s possible that you use a different service principal in production then in development, so what to do? Luckily, we can force parameterization by doing it ourselves in the JSON. In the linked services menu, hit the curly brackets next to the linked service name to show the JSON code:

In the JSON, we can see the hardcoded value for the service principal ID:

We can replace this with a parameter:

"servicePrincipalId": "@{linkedService().servicePrincipalId_office365}",

At the bottom of the JSON, we then need to add a section where we declare this parameter. You need to specify a name, a type and a default value.

        "parameters": {
            "servicePrincipalId_office365": {
                "type": "string",
                "defaultValue": "my_service_principal_id"
            }
        }

The entire JSON (the secret of the service principal is fetched through Azure Key Vault):

{
    "name": "Microsoft365_Graph",
    "properties": {
        "type": "Office365",
        "description": "Graph Data Connect to extract data from O365",
        "annotations": [],
        "typeProperties": {
            "office365TenantId": "365 tenant ID",
            "servicePrincipalTenantId": "Azure tenant ID",
            "servicePrincipalId": "@{linkedService().servicePrincipalId_office365}",
            "servicePrincipalKey": {
                "type": "AzureKeyVaultSecret",
                "store": {
                    "referenceName": "mykeyvault",
                    "type": "LinkedServiceReference"
                },
                "secretName": "service_principal_secret"
            }
        },
        "connectVia": {
            "referenceName": "AutoResolveIntegrationRuntime",
            "type": "IntegrationRuntimeReference"
        },
        "parameters": {
            "servicePrincipalId_office365": {
                "type": "string",
                "defaultValue": "my_service_principal_id"
            }
        }
    }
}

The only “downside” is that you lose the user interface to edit the linked service, as now the entire definition has become dynamic content:

Once the linked service has been properly parameterized, you should be able to change the parameter value in your devops pipelines.


------------------------------------------------
Do you like this blog post? You can thank me by buying me a beer 🙂
Koen Verbeeck

Koen Verbeeck is a Microsoft Business Intelligence consultant at AE, helping clients to get insight in their data. Koen has a comprehensive knowledge of the SQL Server BI stack, with a particular love for Integration Services. He's also a speaker at various conferences.

Recent Posts

dataMinds Connect 2025 – Slides & Scripts

You can find all the session materials for the presentation "Indexing for Dummies" that was…

3 days ago

Cloud Data Driven User Group 2025 – Slides & Scripts

The slidedeck and the SQL scripts for the session Indexing for Dummies can be found…

2 weeks ago

Retro Data 2025 – Slidedeck

You can find the slides of my session on the €100 DWH in Azure on…

3 weeks ago

Secure Logic Apps with OAuth Authorization

I've used Logic Apps a couple of times over the past years for simple workflows,…

4 weeks ago

Free Online Sessions – Building the €100 DWH and Indexing for Dummies

I'm giving two online sessions soon on virtual events that are free to attend. The…

1 month ago

How to Install SQL Server 2025 RC0 on an Azure VM

I wanted to try out the new JSON index which is for the moment only…

1 month ago