azure - 无法从 Azure Kubernetes 服务连接到 Azure SQL DB 服务器
问题描述
我正在尝试在 Azure Kubernetes 中部署 ASP .Net Core Web API 3.0。我的 Dot Net Core Web API 连接到 Azure SQL 数据库。下面是配置
连接字符串
"ConnectionString": "Server=myservername,1433;Initial Catalog=mydbname;Persist Security Info=False;User ID=userid;Password=*******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
部署和服务 yaml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-web-api
labels:
app: my-web-api
spec:
replicas: 2
minReadySeconds: 45
selector:
matchLabels:
app: my-web-api
strategy:
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
type: RollingUpdate
template:
metadata:
labels:
app: my-web-api
spec:
containers:
- name: my-web-api
image: myazureregistry/myapi:latest
imagePullPolicy: Always
ports:
- containerPort: 80
- containerPort: 443
- containerPort: 1433
volumes:
- name: secrets
secret:
secretName: secret-appsettings1
---
apiVersion: v1
kind: Service
metadata:
name: my-web-api
labels:
app: my-web-api
spec:
type: LoadBalancer
ports:
- name: port-8080
port: 8080
targetPort: 80
- name: port-1433
port: 1433
targetPort: 1433
selector:
app: my-web-api
错误
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)
我是 AKS 和 Kubernetes 的新手。请问有人可以为此提供解决方案吗?
解决方案
推荐阅读
- r - R:如何将 300 个 1GB .rds 文件合并为 1 个大 rds 文件而不将它们读入内存?
- google-apps-script - Gmail onEdit Apps 脚本,
- machine-learning - 当测试数据集中不存在相关(目标)变量时评估分类模型
- vue.js - 【编辑器在VUE内使用】无法在编辑器中使用v-model双向绑定文本。我无法在编辑器中获取文本
- websocket - Force LightStreamer 以更高的速度工作
- javascript - 如何将对象数组合并到对象数组包含对象数组
- python-2.7 - 可见VUE输入框的Selenium“消息:元素不可交互”
- json - 使用 JQ 构建 JSON - 转义星号字符
- coq - 类型强制从 nat 到 rat
- python - Python,如何从 URL 解析 HTML?