将Azure资源组中的公共IP关联到Web应用程序? [英] Associate a Public IP in an Azure Resource Group to a Web App?

查看:126
本文介绍了将Azure资源组中的公共IP关联到Web应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Azure资源组.

I'm playing around with Azure Resource Groups.

我创建了一个网上论坛,并在其中创建了一个网络应用. (这只是学术上的事情,当我完成学习后,我将全部删除,因此我不介意共享数据.)该Web应用程序位于 http://woodswild.azurewebsites.net ,实际上您可以转到该地址,它将解决(尽管那里没有任何内容,目前还可以.)

I've created a group, and in it, I've created a web app. (This is all just academic and I'll delete it all when I'm done leaning, so I don't mind sharing the data.) The web app is located at http://woodswild.azurewebsites.net, and indeed you can go to that address and it will resolve (although there is nothing there, which is fine for now.)

然后,在同一资源组中,我还创建了一个静态的公共IP地址.

Then, in the same resource group, I also created a Public IP Address that is static.

一切看起来都不错(无论如何,我认为).但是在Portal UI中,我看到此IP没有任何关联:

That all looks good (I think, anyway). But in the Portal UI, I see that this IP is not associated to anything:

Aaannndd ....我很难弄清楚该怎么做.我使用以下命令在Azure PowerShell中创建了公共IP:

Aaannndd.... I'm having a hard time figuring out how to do that. I created the Public IP from within Azure PowerShell with this command:

New-AzureRmPublicIpAddress -AllocationMethod Static -ResourceGroupName TestRG1 -ReverseFqdn woodswild.centralus.cloudapp.azure.com -Name woodswild.azurewebsites.net -Location "Central US" -DomainNameLabel woodswild

根据本文,该文章解释了New-AzureRmPublicIpAddress命令,没有参数可以声明关联.我在门户网站UI中没有找到一种方法,也无法通过Google找到任何答案.

According to this article that explains the New-AzureRmPublicIpAddress command, there is no parameter to declare an association. I'm not seeing a way to do it in the Portal UI, and I can't find any answers via Google.

我希望/想知道/假设的是,一旦建立了此关联,就可以将IP地址放入浏览器中,它将解析为与

What I'm hoping / wondering / assuming is that once this association is made, you could put the IP Address in a browser and it would resolve to the same place as http://woodswild.azurewebsites.net.

有什么想法吗?谢谢!

推荐答案

实际上不可能为Web App分配静态IP地址.这是因为Web应用程序使用的IP地址不是您专用的,而是位于Azure的Web应用程序服务前面的负载平衡器的前端地址池.

It is not actually possible to assign a static IP address to a Web App. This is because the IP address used by Web Apps isn't used exclusively by you, but instead it is the frontend address pool of the load balancers that sit in front of Azure's Web App service.

但是,Microsoft确实断言,可以为其分配域名的任何Web应用程序都将在其整个生命周期内保留其外部传入地址和外部传出地址.这适用于基本,标准和高级SKU. (它可能也适用于共享-我将不得不挖掘文档)

However Microsoft do assert that any web app that can have a domain name assigned will keep its external incoming address, and external outgoing addresses for the lifetime of the Web App. This applies to Basic, Standard and Premium SKU. (it might apply to Shared too - I'll have to dig out the doc)

您可以使用以下命令找到您的外部传入IP地址(是的,基本上,请对其执行ping操作,然后查看DNS给出了!)

You can find your external incoming IP Address with (yeah, basically, ping it and see what DNS gives!)

Resolve-DnsName (Get-AzureRmWebApp `
        -ResourceGroupName $ResourceGroupName -Name $Name).EnabledHostNames[0]

和带有

(Get-AzureRmWebApp -ResourceGroupName $ResourceGroupName `
                   -Name $Name).OutboundIpAddresses


看来我在这里遇到了第一个障碍,但实际上并没有阅读问题.或者至少我的大脑似乎与那里的单词读了不同的单词! (我会在这里留下错误的答案,因为a,对某人可能有用,b,我可能会将其粘贴到适合一天的实际答案中)


It seems I fell at the first hurdle here, and didn't actually read the question. Or at least my brain seems to have read different words than the ones that are there! (I'll leave the wrong answer here because a, it might be useful to someone, b, I'll likely paste it into an actual answer that it fits one day)

之所以如此令人困惑,是因为Azure用来更新资源的过程并不是立即显而易见的.

The reason this is so confusing is that it is not instantly obvious the process that Azure uses to update resources.

对于在Azure中进行的大多数现有资源更改,该过程类似于

For the majority of existing resource changes that are made in Azure, the process goes something like

  1. 获取信息,将其分配给变量.
  2. 通过分配其他值来更改该变量的属性.
  3. 使用Set-something cmdlet将更改写入Azure.

在为VM分配IP地址的情况下,这是要使用的代码

In the case of assigning an IP address to a VM, this is the code to use

$ipaddr = New-AzureRmPublicIpAddress -Name test1 `
                        -ResourceGroupName win10 `
                        -Location westeurope `
                        -AllocationMethod Static 

$nic = Get-AzureRmNetworkInterface -Name $name `
                        -ResourceGroupName $ResourceGroupName  #1
$nic.IpConfigurations[0].PublicIpAddress = $ipaddr             #2
Set-AzureRmNetworkInterface -NetworkInterface $nic             #3

这篇关于将Azure资源组中的公共IP关联到Web应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆