How do I refresh my access token while implementing a Web Activity on Azure?
I have done the following:
{ "name": "get pp1 runs based on filters", "description": "get pp1 runs based on filters.", "type": "WebActivity", "dependsOn": [ { "activity": "Lookup1", "dependencyConditions": [ "Succeeded" ] } ], "policy": { "timeout": "0.12:00:00", "retry": 0, "retryIntervalInSeconds": 30, "secureOutput": false, "secureInput": false }, "userProperties": [], "typeProperties": { "url": "POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns?api-version=2018-06-01", "method": "POST", "headers": { "Content-Type": "application/json", "Authorization": "https://login.microsoftonline.com/common/oauth2/authorize" }, "body": { "lastUpdatedAfter": "2023-07-23T12:00:36.33Z", "lastUpdatedBefore": "2023-07-24T12:01:35Z", "filters": [ { "operand": "pp1", "operator": "Equals", "values": [ "pipeline1" ] } ] }, "authentication": { "credential": { "referenceName": "credential_ref", "type": "CredentialReference" }, "type": "UserAssignedManagedIdentity" } } },
I am using Authentication as User Assigned Managed Identity
and Integration Runtime as AutoResolveIntegrationRuntime
When I am debugging this, it fails on this webactivtiy and gives me the error: RefreshMsiAccessToken: accessToken null
I read a few links and this is because the token expires every 30 mins to 60 mins. How do I continiously ( or in some time interval ) call the access token every one hour?
As you Created a Web Activity to run based on some filters using: query-by-factory and Authentication as User Assigned Managed Identity
you need not to provide Authorization header in web activity.
You can follow below steps:
User Assigned Managed Identity
in your resource group.
User Assigned Managed Identity
in Data Factory managed identity.
User Assigned Managed Identity
and settings as below:
My pipeline.json:
{
"name": "Web1",
"type": "WebActivity",
"dependsOn": [],
"policy": {
"timeout": "0.12:00:00",
"retry": 0,
"retryIntervalInSeconds": 30,
"secureOutput": false,
"secureInput": false
},
"userProperties": [],
"typeProperties": {
"url": "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DataFactory/factories/{factoryName}/queryPipelineRuns?api-version=2018-06-01",
"method": "POST",
"body": {
"lastUpdatedAfter": "2023-07-24T00:00:00.3345758Z",
"lastUpdatedBefore": "2023-07-26T00:00:00.3686473Z",
"filters": [
{
"operand": "PipelineName",
"operator": "Equals",
"values": [
"pipeline1"
]
}
]
},
"authentication": {
"resource": "https://management.azure.com/",
"credential": {
"referenceName": "credential1",
"type": "CredentialReference"
},
"type": "UserAssignedManagedIdentity"
}
}
}
Output:
Pipeline Ran succesfully: