Based on my understanding, ADF in no way can directly trigger a shell script located in a VM.
You can use Azure automation runbook for that purpose and trigger the runbook via ADF within a dataflow leveraging the webhook activity
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Need assistance with executing a shell script located on a Linux batch server hosted on an Azure Virtual Machine. The requirement involves loading data into a target OLAP system, and after the data is loaded, a Linux shell script located on the batch Linux server needs to be executed. This script will contain complex logic to call APIs and transfer data from the OLAP to the OLTP database.
What steps are needed to achieve this? What are the different methods available, and what prerequisites are required?
Hoping to get answers as soon as possible.
Based on my understanding, ADF in no way can directly trigger a shell script located in a VM.
You can use Azure automation runbook for that purpose and trigger the runbook via ADF within a dataflow leveraging the webhook activity
@Firthouse M G - Thanks for the question and using MS Q&A forum.
Here’s a step-by-step guide to create an Azure Automation runbook using PowerShell to run a Linux shell script on an Azure VM, and then call this runbook from Azure Data Factory (ADF) using a Webhook activity:
Create an Azure Automation Account:
Add the PowerShell Script:
param (
[string]$vmName,
[string]$resourceGroupName,
[string]$scriptPath,
[string]$sshUsername,
[string]$sshPassword
)
# Authenticate with Azure
$connectionName = "AzureRunAsConnection"
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName
Connect-AzAccount -ServicePrincipal -Tenant $servicePrincipalConnection.TenantId `
-ApplicationId $servicePrincipalConnection.ApplicationId `
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint
# Get the public IP of the VM
$publicIP = (Get-AzPublicIpAddress -ResourceGroupName $resourceGroupName -Name "$vmName-ip").IpAddress
# Use SSH to run the shell script on the Linux VM
$command = "sshpass -p $sshPassword ssh -o StrictHostKeyChecking=no $sshUsername@$publicIP 'bash -s' < $scriptPath"
Invoke-Expression $command
Create a Webhook for the Runbook
Webhooks
under Resources
.Add a webhook
.vmName
, resourceGroupName
, scriptPath
, sshUsername
, sshPassword
).Use Webhook Activity in Azure Data Factory (ADF)
Activities
pane, drag a Web
activity to the pipeline canvas.Web
activity to configure it.Settings
tab, set the following:Content-Type
to application/json
. {
"vmName": "your-vm-name",
"resourceGroupName": "your-resource-group",
"scriptPath": "/path/to/your/script.sh",
"sshUsername": "your-ssh-username",
"sshPassword": "your-ssh-password"
}
This setup involves creating an Azure Automation Runbook with PowerShell to execute a Linux shell script on an Azure VM and using an ADF Webhook activity to trigger the runbook. Make sure to replace placeholder values with your actual Azure resources and credentials.
Hope this helps. Do let us know if you have any further issues!
If this answers your query, do click `Accept Answer`
and `Yes`
for was this answer helpful. And, if you have any further query do let us know.