简体   繁体   English

将Azure保留IP映射到端点以进行云服务

[英]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. 我在Azure中拥有一个Cloud Service Worker角色,该角色已设置为保留的IP地址。 The goal of the Reserved IP is so when the worker role makes external requests it will always come from the same IP. 保留IP的目标是当工作者角色发出外部请求时,它总是来自同一个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: 编辑 :使用以下Azure Powershell命令将保留的IP与Cloud Service相关联:

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

This added the following NetworkConfiguration section into the .cscfg file: 以下NetworkConfiguration部分添加到.cscfg文件中:

<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: 现在,当我尝试重新部署服务或更新Azure中的配置设置时,我收到以下错误:

The operation '5e6772fae607ae0ca387457883bf2974' failed: 'Validation Errors: Error validating the .cscfg file against the .csdef file. 操作'5e6772fae607ae0ca387457883bf2974'失败:'验证错误:针对.csdef文件验证.cscfg文件时出错。 Severity:Error, message:ReservedIP 'uld-sender-ip' was not mapped to an endpoint. 严重性:错误,消息:ReservedIP'udl-sender-ip'未映射到端点。 The service definition must contain atleast one endpoint that maps to the ReservedIP..'. 服务定义必须包含至少一个映射到ReservedIP的端点。

So, I have tried adding an Endpoint to the .csdef file like so: 所以,我尝试将端点添加到.csdef文件中,如下所示:

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

In addition, I have entered NetworkTrafficRules to the .csdef like so: 另外,我已经将NetworkTrafficRules输入到.csdef中,如下所示:

<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. 我的理解是端点仅用于工作者/ Web角色之间的内部通信,或者打开端口以接收外部通信。

EDIT : My question is how do you map a Reserved IP to an Endpoint for this scenario? 编辑 :我的问题是如何将保留IP映射到此方案的端点?

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: 为避免在尝试更新配置设置或重新部署服务时出现错误,我运行了Azure Powershell命令以删除与服务保留的ip关联:

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. 然后,我能够在Azure中编辑和保存配置设置,和/或重新部署服务。 Once the service is updated I ran the Azure Powershell command to set the reserved ip association with the service: 更新服务后,我运行Azure Powershell命令来设置与服务的保留IP关联:

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. 希望这有助于某人。

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

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