简体   繁体   English

如何使用 Powershell 7 将保留的 IP 地址分配给 Azure 上的云服务?

[英]How to assign a reserved IP address to a cloud service on Azure using Powershell 7?

I have been using the New-AzureReservedIP cmdlet to create a new reserved IP address in Azure and associate it with an Azure cloud service staging slot.我一直在使用New-AzureReservedIP cmdlet 在 Azure 中创建新的预留 IP 地址,并将其与 Azure 云服务关联。 Basically what is described in this question.基本上这个问题中描述的是什么。 This cmdlet was part of the Azure module.此 cmdlet 是 Azure 模块的一部分。 However, as we know the Azure and AzureRM modules are not available in PS7 anymore.然而,正如我们所知,Azure 和 AzureRM 模块在 PS7 中不再可用。 And this workstep is not even available in the Azure GUI.此工作步骤甚至在 Azure GUI 中都不可用。

As Microsoft recommends switching to PS7 and the Az module I assume that there is another way there to achieve the same thing.正如Microsoft 建议切换到 PS7 和 Az 模块一样,我认为还有另一种方法可以实现相同的目标。 However, so far I was unable to find a solution.但是,到目前为止,我无法找到解决方案。

The problem is that the staging slot requires a reserved IP if the production slot has one.问题是暂存槽需要一个保留的 IP 如果生产槽有一个。 To limit expenses we delete our staging slots after deployment.为了限制费用,我们在部署后删除了我们的暂存槽。 If we'd just keep and update it, that would not be a problem.如果我们只是保留并更新它,那将不是问题。 Also, I was unable to find a way to re-use an existing reserved IP (that was created with New-AzureReservedIP previously) for the next staging deployment, so far I always needed to create a new one using New-AzureReservedIP .此外,我无法找到一种方法来重新使用现有的预留 IP(之前使用New-AzureReservedIP创建)进行下一次分段部署,到目前为止,我总是需要使用New-AzureReservedIP创建一个新的。 I ended up having quite a few reserved IP addresses which I don't use anymore so I wonder if they can be recycled somehow?我最终有很多保留的 IP 地址,我不再使用了,所以我想知道它们是否可以以某种方式回收?

What would be best practice to solve this in PS7?在 PS7 中解决这个问题的最佳做法是什么?

Reserved IP belongs to ASM API (Classic) and will be deprecated by 2023. Hence it doesn't exist in ARM.保留的 IP 属于 ASM API(经典),将在 2023 年弃用。因此它在 ARM 中不存在。 The new ARM API doesn't support this functionality.新的 ARM API 不支持此功能。 In ARM you have the option to use static Public IP (IP owned by Microsoft) or Public IP Prefix which is when you buy the IP address/IP range. In ARM you have the option to use static Public IP (IP owned by Microsoft) or Public IP Prefix which is when you buy the IP address/IP range.

New-AzPublicIpAddress https://docs.microsoft.com/en-us/powershell/module/az.network/new-azpublicipprefix?view=azps-4.5.0 New-AzPublicIpAddress https://docs.microsoft.com/en-us/powershell/module/az.network/new-azpublicipprefix?view=azps-4.5.0

New-AzPublicIpPrefix https://docs.microsoft.com/en-us/powershell/module/az.network/new-azpublicipaddress?view=azps-4.5.0 New-AzPublicIpPrefix https://docs.microsoft.com/en-us/powershell/module/az.network/new-azpublicipaddress?view=azps-4.5.0

But one thing to note is that if you are using App Service you actually get a Static Public IP for your App Service but that one is shared with many other customers hence you need to use your App Service URL eg.但要注意的一件事是,如果您使用的是应用服务,您实际上会得到一个 Static Public IP 用于您的应用服务,但该服务与许多其他客户共享,因此您需要使用您的应用服务 ZE6B391A8D2C4D45902A23A8B655702A23A8B66 https://[AppServiceName].azurewebsites.net or add a Custom Domain to your App Service. https://[AppServiceName].azurewebsites.net 或将自定义域添加到您的应用服务。

So if you really need a Public IP that is not shared you have to move over to IaaS eg.因此,如果您确实需要未共享的公共 IP,您必须转移到 IaaS,例如。 Virtual Machines虚拟机

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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