简体   繁体   English

从 Azure 应用服务(Web App)访问 Azure 容器实例

[英]Access Azure Container Instance from Azure App Service (Web App)

I've a microservice that runs on a Azure Container Instance, and a WebApp that run on App Service.我有一个在 Azure 容器实例上运行的微服务和一个在应用服务上运行的 WebApp。 I want my WebApp to call my microservice (that is private).我希望我的 WebApp 调用我的微服务(即私有的)。 I've created a virtual network (v-net) with a subnet.我创建了一个带有子网的虚拟网络 (v-net)。 But Azure says my two services cannot be on the same subnet because there are not delegated by the same resource.但是 Azure 说我的两个服务不能在同一个子网上,因为没有由同一个资源委托。 WebApp is delegated to Microsoft.Web/serverfarms and Azure Container Service is delegated to: Microsoft.ContainerInstance/containerGroups. WebApp 委托给 Microsoft.Web/serverfarms,Azure 容器服务委托给:Microsoft.ContainerInstance/containerGroups。 How can I achieve what I want?我怎样才能达到我想要的? (call the microservice from the webapp?) (从 webapp 调用微服务?)

Even though it's not exactly how you're trying to achieve, you can always use a message broker to decouple and enable the communication between 1-N microservices using a Service Bus Topic.即使这不是您想要实现的方式,您也始终可以使用消息代理来解耦并使用服务总线主题启用 1-N 微服务之间的通信。

Among the benefits:其中的好处:

  • it's the fact Web App won't need to know the URI to communicate with the Microservices这是事实 Web 应用程序不需要知道与微服务通信的 URI
  • You can add more microservices to react to a particular type of message in the future with no code changes (besides the subscription of the new microservice to a specific topic)您可以添加更多微服务以在将来对特定类型的消息做出反应,而无需更改代码(除了新微服务对特定主题的订阅)
  • it's reliable and durable它可靠耐用
  • well tested and used in all kind of applications (ecommerces, crm, erp, etc)经过良好测试并用于各种应用程序(电子商务、crm、erp 等)
  • you won't need to deal with such network configuration issues.您无需处理此类网络配置问题。

You can read more about my recommended solution:您可以阅读有关我推荐的解决方案的更多信息:

https://microservices.io/patterns/communication-style/messaging.html https://microservices.io/patterns/communication-style/messaging.html

https://docs.microsoft.com/en-us/azure/architecture/microservices/design/interservice-communication https://docs.microsoft.com/en-us/azure/architecture/microservices/design/interservice-communication

https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/service-to-service-communication https://docs.microsoft.com/en-us/dotnet/architecture/cloud-native/service-to-service-communication

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

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