通过 powershell 在云服务上设置 Azure 保留 IP

Set Azure Reserved IP on cloud service via powershell

正如标题所说,我无法为我的云服务分配IP。

我关注了很多论坛和 Whosebug articles/posts,但问题仍然存在。

当我尝试 运行

Set-AzureReservedIPAssociation -ReservedIPName primosguardo365reservedip -ServiceName primosguardo365

我收到这个错误

Set-AzureReservedIPAssociation : ResourceNotFound: No deployments were found.
At line:1 char:1
+ Set-AzureReservedIPAssociation -ReservedIPName primosguardo365reserve ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureReservedIPAssociation], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.SetAzureReservedIPAssociationCmdlet

但如果我尝试使用相同的名称获取资源

λ  Get-AzureReservedIP

ReservedIPName       : Group Primosguardo365 primosguardo365reservedip
Address              : **.**.**.**
Id                   : ******************
Label                :
Location             : West Europe
State                : Created
InUse                : False
ServiceName          :
DeploymentName       :
VirtualIPName        :
OperationDescription : Get-AzureReservedIP
OperationId          : ************************
OperationStatus      : Succeeded


λ  Get-AzureService "primosguardo365"

ServiceName             : primosguardo365
Url                     : https://management.core.windows.net.................
Label                   : primosguardo365
Description             : primosguardo365
Location                : West Europe
AffinityGroup           :
Status                  : Created
ExtendedProperties      : {[ResourceGroup, Primosguardo365], [ResourceLocation, westeurope], [ProvisioningSource,
                          AzureResourceManager]}
DateModified            : 28/03/2017 12:13:20
DateCreated             : 28/03/2017 11:26:03
ReverseDnsFqdn          :
WebWorkerRoleSizes      : {}
VirtualMachineRoleSizes : {}
OperationDescription    : Get-AzureService
OperationId             : ****************************
OperationStatus         : Succeeded

有人有什么建议吗?

提前致谢!

编辑:

VIP 只能分配给已部署的 PRODUCTION 实例。

但这没用,因为 CloudServices 已经有静态 IP。

感谢大家!

在我的测试中,我重现了你的错误,我只是通过新门户创建了一个云服务,然后将一个保留的IP地址关联到它,错误就发生了。

PS C:\Users> Set-AzureReservedIPAssociation -ReservedIPName my9 -ServiceName "jasontest323"
Set-AzureReservedIPAssociation : ResourceNotFound: No deployments were found.
At line:1 char:1
+ Set-AzureReservedIPAssociation -ReservedIPName my9 -ServiceName "jaso ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureReservedIPAssociation], CloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.SetAzureReservedIPAssociationCmdlet

之后,我创建了另一个云服务和一个虚拟机,然后为这个云服务分配了一个保留的IP地址,就可以了。

PS C:\Users> Set-AzureReservedIPAssociation -ReservedIPName my9 -ServiceName "jasonvm3659"

OperationDescription           OperationId                          OperationStatus
--------------------           -----------                          ---------------
Set-AzureReservedIPAssociation 05ccff35-5642-7cc6-9c6b-b5dfe2d1603d Succeeded

所以,我检查了两个云服务的状态,我发现当 Production 为 运行 时,该命令将起作用。

我们可以使用 PowerShell 检查部署:

PS C:\Users> Get-AzureDeployment -ServiceName jasontest323
Get-AzureDeployment : ResourceNotFound: No deployments were found.
OperationID : '27da300bc3c67a5bbdbc954c1c19e3e7'
At line:1 char:1
+ Get-AzureDeployment -ServiceName jasontest323
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Get-AzureDeployment], ComputeCloudException
    + FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.HostedServices.GetAzureDeploymentCommand

PS C:\Users> Get-AzureDeployment -ServiceName jasonvm3659


SdkVersion                :
RollbackAllowed           : False
Slot                      : Production
Name                      : jasonvm3659
DeploymentName            : jasonvm3659
Url                       : http://jasonvm3659.cloudapp.net/
Status                    : Running
CurrentUpgradeDomain      : 0
CurrentUpgradeDomainState :
UpgradeType               :
RoleInstanceList          : {jasonvm}
Configuration             : <ServiceConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                            xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
                              <Role name="jasonvm">
                                <Instances count="1" />
                              </Role>
                            </ServiceConfiguration>
DeploymentId              : fc627acb502a4a979b08c42f69cccf72
Label                     : jasonvm3659
VNetName                  : Group jasontest321 jasontest321
DnsSettings               :
OSVersion                 :
RolesConfiguration        : {[jasonvm, Microsoft.WindowsAzure.Commands.ServiceManagement.Model.RoleConfiguration]}
VirtualIPs                : {jasonvm3659ContractContract}
ReservedIPName            : my9
CreatedTime               : 3/29/2017 1:10:28 PM
LastModifiedTime          : 3/29/2017 1:27:42 PM
Locked                    : False
InternalLoadBalancerName  :
LoadBalancers             : {}
ExtensionConfiguration    :
ServiceName               : jasonvm3659
OperationDescription      : Get-AzureDeployment
OperationId               : f8b8xxxx-xxxx-xxxx-xxxx-xxxx2cdc1daa
OperationStatus           : Succeeded

保留 IP 适用于经典模块,仅用于通过 VIP 公开的 VM云服务实例角色

所以我们应该先用 powershell Get-AzureDeployment -ServiceName primosguardo365 检查部署。