简体   繁体   中英

Map Azure Reserved IP to Endpoint for Cloud Service

I have a Cloud Service Worker Role in Azure which has been set up with a Reserved IP address. The goal of the Reserved IP is so when the worker role makes external requests it will always come from the same IP. No external traffic is received by the service and no internal communication is required.

EDIT : The Reserved IP was associated with the Cloud Service using the following Azure Powershell command:

Set-AzureReservedIPAssociation -ReservedIPName uld-sender-ip -ServiceName uld-sender

This added the following NetworkConfiguration section into the .cscfg file:

<NetworkConfiguration>
    <AddressAssignments>
      <ReservedIPs>
        <ReservedIP name="uld-sender-ip" />
      </ReservedIPs>
    </AddressAssignments>
  </NetworkConfiguration>

Now, when I try and re-deploy the service or update the configuration settings in Azure, I get the following error:

The operation '5e6772fae607ae0ca387457883bf2974' failed: 'Validation Errors: Error validating the .cscfg file against the .csdef file. Severity:Error, message:ReservedIP 'uld-sender-ip' was not mapped to an endpoint. The service definition must contain atleast one endpoint that maps to the ReservedIP..'.

So, I have tried adding an Endpoint to the .csdef file like so:

<Endpoints>
  <InternalEndpoint name="uld-sender-ip" protocol="tcp" port="8080" />
</Endpoints>

In addition, I have entered NetworkTrafficRules to the .csdef like so:

<NetworkTrafficRules>
    <OnlyAllowTrafficTo>
      <Destinations>
        <RoleEndpoint endpointName="uld-sender-ip" roleName="Sender"/>
      </Destinations>
      <AllowAllTraffic/>
    </OnlyAllowTrafficTo>
  </NetworkTrafficRules>

But I still get the same error.

My understanding is that endpoints are only required for internal communication between worker/web roles, or to open a port to receive external communication.

EDIT : My question is how do you map a Reserved IP to an Endpoint for this scenario?

To avoid getting the error while trying to update the configuration settings or re-deploy the service, I ran the Azure Powershell command to remove the reserved ip association with the service:

Remove-AzureReservedIPAssociation -ReservedIPName uld-sender-ip -ServiceName uld-sender

Then I was able to edit and save the configuration settings in Azure, and/or re-deploy the service. Once the service is updated I ran the Azure Powershell command to set the reserved ip association with the service:

Set-AzureReservedIPAssociation -ReservedIPName uld-sender-ip -ServiceName uld-sender

This is obviously not the ideal solution but at least I can make changes to the service if needed. Hope this helps someone.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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