0

I have a VM running on Azure running a web server, only internal connections are allowed and I'm using a private IP. Can connect to it from my local machine as intended.

Now I'm trying to connect to that web server from an Azure Automation Powershell runbook. But the server only returns a "Unable to connect" error message.

Everything is in the same resource group and I do not want to run the runbook on the VM itself, it should run as a serverless script. How do I connect/refer to the private IP? Do I need to setup some specific network rules as well for the VM in order to allow connections from Azure Automation?

DarkWizard96582
  • 63
  • 1
  • 1
  • 5

2 Answers2

0

Azure Automation cannot talk to your VM. The fact that it is in the same resource group is not relevant. When you run jobs on in Azure Automation, under the hood they are running on machines that Microsoft provisions and manages for you. If your VM is on your own virtual network without an external IP (or on-prem) then there is no way it to connect to it from these machines.

If you wanted to run tasks against this machine, you would need to create an Azrue Autoamtion Hybrid worker on the same vnet (or on that machine) which has connectivity to it. A Hybrid Work is a VM that you create that has the Hybrid Worker tools installed. You can then run Azure Automation jobs that execute on that machine.

Sam Cogan
  • 4,124
  • 7
  • 44
  • 76
0

Hybrid Runbook Worker would definitely be a solution here, but it kinda ruins the serverless approach, so I suggest using Invoke-AzVMRunCommand in your runbook. It can invoke PowerShell script from a file (-CommandId 'RunPowerShellScript').

As for the .ps1 file itself, it could be stored in an Azure Storage account and downloaded at the time of execution or even be created by this very runbook and saved under $env:TEMP location and then invoked from there.

Reference:

https://www.hernanjlarrea.com/index.php/azure-native-remoting-options-for-your-iaas-resources/

aidden
  • 543
  • 2
  • 6