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

问题描述 投票:2回答:2

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

java azure azure-web-sites azure-virtual-machine windows-firewall
2个回答
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
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.