Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Azure Data Factory pipeline to refresh a Power BI dataset using a Service Principal, and Azure Key Vault.
{
"name": "pipeline1",
"properties": {
"activities": [
{
"name": "Call Dataset Refresh",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Get AAD Token",
"dependencyConditions": [
"Succeeded"
]
}
],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": true,
"secureInput": true
},
"typeProperties": {
"url": {
"value": "@concat('https://api.powerbi.com/v1.0/myorg/groups/',pipeline().parameters.PBIAppWorkspaceId,'/datasets/',pipeline().parameters.PBIDatasetId,'/refreshes')",
"type": "Expression"
},
"method": "POST",
"headers": {
"Authorization": {
"value": "@concat(string(activity('Get AAD Token').output.token_type),' ',string(activity('Get AAD Token').output.access_token))",
"type": "Expression"
}
},
"body": {
"helloww": "worldddd"
}
}
},
{
"name": "Get AAD Token",
"type": "WebActivity",
"dependsOn": [
{
"activity": "Get TenantId from AKV",
"dependencyConditions": [
"Succeeded"
]
},
{
"activity": "Get ClientId from AKV",
"dependencyConditions": [
"Succeeded"
]
},
{
"activity": "Get Secret from AKV",
"dependencyConditions": [
"Succeeded"
]
}
],
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": true,
"secureInput": true
},
"typeProperties": {
"url": {
"value": "@concat('https://login.microsoftonline.com/',activity('Get TenantId from AKV').output.value,'/oauth2/token')",
"type": "Expression"
},
"method": "POST",
"headers": {
"Content-Type": "application/x-www-form-urlencoded"
},
"body": {
"value": "@concat('grant_type=client_credentials&resource=https://analysis.windows.net/powerbi/api&client_id=',activity('Get ClientId from AKV').output.value,'&client_secret=',encodeUriComponent(activity('Get Secret from AKV').output.value))",
"type": "Expression"
}
}
},
{
"name": "Get TenantId from AKV",
"type": "WebActivity",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": true,
"secureInput": true
},
"typeProperties": {
"url": {
"value": "@concat(pipeline().parameters.KeyVaultDNSName,'secrets/',pipeline().parameters.SecretName_TenantId,'/',pipeline().parameters.SecretVersion_TenantId,'?api-version=7.0')",
"type": "Expression"
},
"method": "GET",
"body": {
"simple": "body"
},
"authentication": {
"type": "MSI",
"resource": "https://vault.azure.net"
}
}
},
{
"name": "Get ClientId from AKV",
"type": "WebActivity",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": true,
"secureInput": true
},
"typeProperties": {
"url": {
"value": "@concat(pipeline().parameters.KeyVaultDNSName,'secrets/',pipeline().parameters.SecretName_SPClientId,'/',pipeline().parameters.SecretVersion_SPClientId,'?api-version=7.0')",
"type": "Expression"
},
"method": "GET",
"body": {
"simple": "body"
},
"authentication": {
"type": "MSI",
"resource": "https://vault.azure.net"
}
}
},
{
"name": "Get Secret from AKV",
"type": "WebActivity",
"policy": {
"timeout": "7.00:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": true,
"secureInput": true
},
"typeProperties": {
"url": {
"value": "@concat(pipeline().parameters.KeyVaultDNSName,'secrets/',pipeline().parameters.SecretName_SPSecret,'/',pipeline().parameters.SecretVersion_SPSecret,'?api-version=7.0')",
"type": "Expression"
},
"method": "GET",
"body": {
"simple": "body"
},
"authentication": {
"type": "MSI",
"resource": "https://vault.azure.net"
}
}
}
],
"parameters": {
"SecretName_TenantId": {
"type": "String",
"defaultValue": "TenantId"
},
"SecretName_SPClientId": {
"type": "String",
"defaultValue": "ClientId"
},
"SecretName_SPSecret": {
"type": "String",
"defaultValue": "ClientSecret"
},
"KeyVaultDNSName": {
"type": "string"
},
"SecretVersion_TenantId": {
"type": "string"
},
"SecretVersion_SPClientId": {
"type": "string"
},
"SecretVersion_SPSecret": {
"type": "string"
},
"PBIAppWorkspaceId": {
"type": "string"
},
"PBIDatasetId": {
"type": "string"
}
}
},
"type": "Microsoft.DataFactory/factories/pipelines"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.