Reserved IP for Azure Cloud Service doesn't persist

若如初见. 提交于 2019-12-07 06:28:44

问题


I'm struggling to get to grips with Reserved IP addresses in an Azure Cloud Service.

I have a Cloud Service with Staging and Productions deployments and I need at least the Production deployment to have a stable IP address. I set up 2 Reserved IP addresses as described here then assigned my reserved IPs to the Production and Staging deployments with Power Shell:

Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP1 -ServiceName mycloudservice -Slot “Production”
Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP2 -ServiceName mycloudservice -Slot “Staging”

All well and good the reserved IPs get assigned to the respective instances and swapping maintains the correct addresses. The problem is if I delete one of the deployments and redeploy the IP address is not maintained.

I also tried assigning a reserved IP address to the cloud service without specifying a "Slot" and it assigned fine but does not seem to get used in either Production or Staging deployments.

Set-AzureReservedIPAssociation -ReservedIPName MyReservedIP -ServiceName mycloudservice

My usual workflow would be to deploy to Staging then swap with Production once I have tested all is working fine. With this scenario how can I ensure the Production deployment always gets a Reserved IP address when I swap from Staging, even if there is no current Production instance deployed?

The Azure documentation says "IP address for the cloud service will be the same even as resources are shutdown or deallocated" so shouldn't my previously assigned Production IP address be maintained even if I delete the Production instance and then swap from Staging?


回答1:


This worked for me:

Create your reserved IPs

New-AzureReservedIP -ReservedIPName "ip1" -Location "East US 2"

New-AzureReservedIP -ReservedIPName "ip2" -Location "East US 2"

Deploy to the production slot with the following network configuration in your .cscfg file:

<NetworkConfiguration>
    <AddressAssignments>
      <ReservedIPs>
        <ReservedIP name="ip1" />
      </ReservedIPs>
    </AddressAssignments>
  </NetworkConfiguration>

Deploy to the staging slot with the following configuration:

<NetworkConfiguration>
    <AddressAssignments>
      <ReservedIPs>
        <ReservedIP name="ip2" />
      </ReservedIPs>
    </AddressAssignments>
  </NetworkConfiguration>

Continue using your normal workflow - deploy to staging, then swap to production. The IP addresses should stay associated with their slots (ip1 in production and ip2 in staging).



来源:https://stackoverflow.com/questions/32919192/reserved-ip-for-azure-cloud-service-doesnt-persist

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!