【发布时间】:2021-01-28 12:32:53
【问题描述】:
我正在尝试将我的应用引擎 flex 服务连接到共享项目中的云 sql 数据库。
我已将应用引擎默认用户和应用引擎 flex 用户作为 SQL 管理员添加到共享项目中。
现在我正在尝试使用以下连接字符串将应用引擎容器连接到云 sql 实例:
"Server=cloudsql;Database=cliche;User Id=user;Password=password;"
但是,连接总是以给定的连接字符串失败。
[13:57:37 ERR] An error occurred using the connection to database 'cliche' on server 'cloudsql'.
[13:57:37 ERR] An exception occurred while iterating over the results of a query for context type 'IKL.Data.ApplicationDbContext'.
Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 40 - Could not open a connection to SQL Server)
根据要求,我在此处提供 app.yaml:
runtime: aspnetcore
env: flex
service: platform
manual_scaling:
instances: 1
resources:
cpu: 2
memory_gb: 1.5
disk_size_gb: 10
beta_settings:
cloud_sql_instances: shared-resources-291914:europe-west3:edutec-mssql=tcp:1433
【问题讨论】:
-
您如何使用 App Engine Flex 配置 Cloud SQL 连接?在 app.yaml 中?你能分享你的 app.yaml 吗?
-
我正在使用 app yaml 进行配置,对于缺乏细节深表歉意。
-
数据库有公网IP吗?还是只部署在私有 IP 上?
-
部署在公网ip
-
你能分享一下你配置和连接数据库的代码吗?
标签: asp.net google-app-engine google-cloud-platform google-cloud-sql