简体   繁体   English

从Azure应用服务连接到MongoDB Atlas集群

[英]Connect to MongoDB Atlas cluster from an Azure App Service

I have a web app on Azure that connect to a MongoDB cluster hosted on Atlas (cloud.mongodb.com). 我在Azure上有一个Web应用程序,它连接到Atlas(cloud.mongodb.com)上托管的MongoDB集群。

I'd like to use Atlas so I don't have to care about MongoDb configurations. 我想使用Atlas,所以我不必关心MongoDb配置。 The issue is that I get a timeout connecting my cluster. 问题是我连接群集时超时。 I have to set the app service ip in my mongo cluster whitelist, but If I try to download the page http://www.whatsmyip.org/ I get every time a different IP. 我必须在我的mongo集群白名单中设置应用服务ip,但是如果我尝试下载页面http://www.whatsmyip.org/我每次都会获得不同的IP。

On the azure panel I've tried everything, set a VNET integration, set an ASE, a gateway. 在天蓝色的面板上,我尝试了一切,设置了VNET集成,设置了ASE,一个网关。 I really don't know how to expose the public IP. 我真的不知道如何揭露公共IP。

However I have a VM that can query the mongo cluster, it has a Network interface with a public ip and a nsg (firewall). 但是我有一个可以查询mongo集群的虚拟机,它有一个带有公共IP和nsg(防火墙)的网络接口。

To expand Paolo's answer as it wasn't too clear and I had to do some extra research. 为了扩大Paolo的答案,因为它不太清楚,我不得不做一些额外的研究。

In the Azure portal, select your App Service and scroll down to the Settings section in the menu (headed by overview) and select properties. 在Azure门户中,选择您的应用程序服务,然后向下滚动到菜单中的“设置”部分(按概述为首)并选择属性。

Scroll down until you find the Outbound IP Addresses. 向下滚动,直到找到出站IP地址。 These are the ones you will want to add to your whitelist in Atlas. 这些是您要添加到Atlas白名单中的内容。

Useful Links: https://blogs.msdn.microsoft.com/waws/2017/02/01/how-do-i-determine-the-outbound-ip-addresses-of-my-azure-app-service/ 有用链接: https//blogs.msdn.microsoft.com/waws/2017/02/01/how-do-i-determine-the-outbound-ip-addresses-of-my-azure-app-service/

You can whitelist 0.0.0.0/0 and then rely on user authentication. 您可以将0.0.0.0/0列入白名单,然后依赖用户身份验证。 Alternatively, you can use AWS as an alternative to Azure and use VPC peering. 或者,您可以使用AWS作为Azure的替代方案并使用VPC对等。

https://www.mongodb.com/blog/post/introducing-vpc-peering-for-mongodb-atlas https://www.mongodb.com/blog/post/introducing-vpc-peering-for-mongodb-atlas

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

相关问题 无法从 nodejs(express) 简单应用程序连接到 mongodb Atlas 集群 - Not able to connect to mongodb Atlas cluster from nodejs(express) simple app 无法从 kubernetes 集群连接到 mongodb atlas 集群 - Unable to connect to mongodb atlas cluster from a kubernetes cluster 如何将atlas mongodb与集群连接 - how to connect atlas mongodb with a cluster 使用 mongoengine 连接到 MongoDB atlas 集群 - Connect to MongoDB atlas cluster with mongoengine 使用 react-native 应用程序连接到 MongoDB Atlas Cluster 数据库 - Connect to MongoDB Atlas Cluster db with react-native app Node.js 应用无法连接到 MongoDB Atlas 集群 - Node.js app cannot connect to MongoDB Atlas cluster 从Google App Engine连接到MongoDB Atlas - Connect to MongoDB Atlas from Google App Engine 如何使用 pyspark 从 databricks 集群连接到 mongodb Atlas - how to connect to mongodb Atlas from databricks cluster using pyspark 通过 vnet 对等连接将 Azure 应用服务连接到 MongoDB Atlas - Connecting Azure app service to MongoDB Atlas across vnet peering connection PyMongo 无法从 Azure 容器实例连接到 MongoDB Atlas - PyMongo Cant connect to MongoDB Atlas from Azure Container Instance
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM