打开自定义入站防火墙端口,例8077以任何方式在azure中使用java

时间:2017-12-12 13:46:35

标签: java azure azure-web-sites azure-virtual-machine windows-firewall

我正在使用Java在Azure(Microsoft)中启动一个Windows实例,并尝试为我的工作打开一些入站端口,如445,8077。 我也尝试使用安全组端口打开,但它只打开安全组级别的入站端口,而不是系统级别。 为我提供一些解决方案,以便我可以在发布之前或发布之后打开也可以。我在AWS中做了同样的事情,如下面的网址所示:
image

2 个答案:

答案 0 :(得分:2)

如果我的理解是正确的,那么您在Azure中使用Windows VM(Iaas服务)。它与AWS实例相同,您可以使用Power Shell在Windows防火墙上打开端口8077。

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

在Azure VM上,您还需要Azure NSG上的开放端口。 enter image description here

更新

如果要使用Azure java SDK执行此操作,可以使用此example

我修改示例以添加自定义脚本扩展,如下所示:

        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();

您可以在Github上查看我的code

答案 1 :(得分:1)

不,我们不允许在PaaS上打开自定义端口。您必须移至Azure VM才能打开自定义端口。