简体   繁体   中英

Open custom inbound firewall ports e.g. 8077 by any way using java in azure

I am launching one windows instance in Azure(Microsoft) using Java and trying to open few inbound ports like 445, 8077 for my work. I have also tried using Security groups port opening but it is only opening the inbound ports at security group level, not at the system level. Provide me some solution so that I can open either before launch itself or after launch is also fine. I have done the same thing in AWS as asked in below URL:
Open some custom inbound ports eg 8077 by using 80 or 3389

If my understanding is right,you use a Windows VM in Azure(Iaas service). It is same with AWS instance, you could use Power Shell to open port 8077 on Windows Firewall.

netsh advfirewall firewall add rule name="Open Port 8077" dir=in action=allow protocol=TCP localport=8077

On Azure VM, you also need open port on Azure NSG . 在此处输入图片说明

Update:

If you want to use Azure java SDK to do this, you could use this example .

I modify the example to add Custom Script Extension like below:

        windowsVM.update()
            .defineNewExtension("shuitest")
            .withPublisher("Microsoft.Compute")
            .withType("CustomScriptExtension")
            .withVersion("1.9")
            .withMinorVersionAutoUpgrade()
            .withPublicSetting("commandToExecute", "netsh advfirewall firewall add rule name=\"Open Port 8077\" dir=in action=allow protocol=TCP localport=8077")
            .attach()
        .apply();

You could check my code on Github.

No, we don't allow to open custom port on PaaS. You have to move to Azure VM to be able to open custom ports.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM