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

时间:2017-03-28 10:29:14

标签: powershell azure azure-cloud-services azure-resource-manager azure-resource-group

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

我已经关注了很多论坛和StackOverflow文章/帖子,但我仍然存在这个问题。

当我尝试运行时

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。

感谢所有人!

1 个答案:

答案 0 :(得分:0)

在我的测试中,我重现了您的错误,我只是通过新门户创建云服务,然后将保留的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

所以,我检查两个云服务的状态,我发现在生产运行时,该命令将起作用。 enter image description here

enter image description here

我们可以使用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公开的虚拟机云服务实例角色

因此我们应首先使用powershell Get-AzureDeployment -ServiceName primosguardo365检查部署。