Search code examples
azurepowershellvirtual-machineazure-nsg

How to run a Azure Powershell cmdlets on a VM when outbound Internet access is restricted


I am using Powershell script that resides in a VM to retrieve the list of resources in a subscription. Currently I have the outbound internet enabled on the NSG of the VM. But I would like to restrict the outbound internet access in future.

Is there a way to run the powershell script when internet access is denied ?


Solution

  • The Run Command feature can run scripts on your virtual machines remotely by using the VM agent. To function correctly, Run Command requires connectivity (port 443) to Azure public IP addresses. If you're blocking traffic on the virtual machine, you can use service tags to allow traffic to Azure public IP addresses by using the AzureCloud tag.