connect private api with azure automation

Arif Usman 421 Reputation points
2022-10-09T01:36:24.78+00:00

folks,
I have Firewall setup in azure vm (ip 10.10.10.45). Only to way to get api, from another vm (vm2 from postman.
for example, I am running api in vm2 (192.168.45.45) 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 = 'http://10.10.10.45:8080/rest/vpn/v1/tunnels'
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 https://learn.microsoft.com/en-us/azure/automation/how-to/private-link-security#connect-to-a-private-endpoint/
but still getting error
Invoke-RestMethod: C:\Temp\jkpozav2.gre\fae8e10d-fd27-40ac-8005-48081a98712a.ps1:10
Line |
10 | $RESULTS = Invoke-RestMethod
@params
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
    2022-10-09T04:51:44.193+00:00

    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)

    https://learn.microsoft.com/en-us/azure/automation/extension-based-hybrid-runbook-worker-install?tabs=windows%2Carm-template
    https://learn.microsoft.com/en-us/azure/automation/automation-hybrid-runbook-worker