connect private api with azure automation

Arif Usman 421 Reputation points

I have Firewall setup in azure vm (ip Only to way to get api, from another vm (vm2 from postman.
for example, I am running api in vm2 ( in postman. It works fine if i ran in vm2 because i had forward rule to fireall api vm setup.
My powershell works fine in VM2 as below.
$params = @{
Uri = ''
Headers = @{ 'X-API-Token' = "123456adcasdfecasdfx" }
Method = 'GET'
Body = $jsonSample
ContentType = 'application/json'

$RESULTS = Invoke-RestMethod @params

Now i would like to run in Azure Automation. I am trying to follow this doc
but still getting error
Invoke-RestMethod: C:\Temp\jkpozav2.gre\fae8e10d-fd27-40ac-8005-48081a98712a.ps1:10
Line |
10 | $RESULTS = Invoke-RestMethod
now when i created private endpoint, i used VM2...

Any thoughts?

Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,144 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Maxim Sergeev 6,566 Reputation points Microsoft Employee

    Hi there,

    If you need to get the data from the Azure VM only, just register your VM as a Hybrid Worsker Server. And run the script in HRW server instead of Azure Sandbox with a private link (it's a good approach for enterprise-scaled solutions, but not for your scenario imho)