Azure Data Factory v2 Linked Services Testing
If you are deploying lots of Linked Services to an environment it would be nice to run a test that proves they connect successfully. This can validate many things, including:
Key Vault Secrets have also been deployed
Permissions applied to your secrets
Integration Runtime is up and working
Firewall ports opened
User Permissions deployed
PowerShell and the Azure REST API to the rescue. Firstly you will need a function I previously blogged about called getBearer to get a Bearer token.
I’m going to assume that you want to run this script in a non interactive mode as part of a Release Pipeline through some like Azure DevOps. This first function will ensure we are connected to Azure:
If you are running locally in PowerShell this ask you to login (ONCE!), if you are running as Azure PowerShell it will do nothing because you are already connected.
Next we need to get your Linked Service as JSON. The REST API has a nice method to do this:
Now the interesting bit, this API call I had to find using the web UI and Fiddler. So yes this is an undocumented API call. Note that the API version shows it as being in preview. Hopefully it will remain unchanged:
Put it altogether:
The final output should be a True or False based on whether it connected or not.
The full script can be found here on GitHub.