我正在尝试公开两个服务(Web API和Chat Bot),它们通过 Service Fabric Mesh 网络的入口控制器在内部打开相同的端口。
运行下面的定义总是使两个服务之一失败。
我不清楚的是什么
文件:
{
"$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"resources": [
{
"apiVersion": "2018-07-01-preview",
"name": "contosomaintenance",
"type": "Microsoft.ServiceFabricMesh/applications",
"location": "westeurope",
"dependsOn": [
"Microsoft.ServiceFabricMesh/networks/contosomaintenance-network"
],
"properties": {
"services": [
{
"name": "contosomaintenance-api",
"properties": {
"description": "Contoso Maintenance REST API",
"osType": "Linux",
"codePackages": [
{
"name": "contosomaintenance-api",
"image": "robinmanuelthiel/contosomaintenance-api:latest",
"endpoints": [
{
"name": "http",
"port": 80
},
{
"name": "https",
"port": 443
}
],
"resources": {
"requests": {
"cpu": "0.5",
"memoryInGB": "1"
}
}
}
],
"replicaCount": "1",
"networkRefs": [
{
"name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'contosomaintenance-network')]"
}
]
}
},
{
"name": "contosomaintenance-bot",
"properties": {
"description": "Contoso Maintenance Chat Bot",
"osType": "Linux",
"codePackages": [
{
"name": "contosomaintenance-bot",
"image": "robinmanuelthiel/contosomaintenance-bot:latest",
"endpoints": [
{
"name": "http",
"port": 80
},
{
"name": "https",
"port": 443
}
],
"resources": {
"requests": {
"cpu": "0.5",
"memoryInGB": "1"
}
}
}
],
"replicaCount": "1",
"networkRefs": [
{
"name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'contosomaintenance-network')]"
}
]
}
}
]
}
},
{
"apiVersion": "2018-07-01-preview",
"name": "contosomaintenance-network",
"type": "Microsoft.ServiceFabricMesh/networks",
"location": "westeurope",
"dependsOn": [],
"properties": {
"description": "Contoso Maintenance Network",
"addressPrefix": "10.0.0.0/22",
"ingressConfig": {
"layer4": [
{
"name": "contosomaintenance-api-ingress-http",
"publicPort": "20001",
"applicationName": "contosomaintenance",
"serviceName": "contosomaintenance-api",
"endpointName": "http"
},
{
"name": "contosomaintenance-api-ingress-bot",
"publicPort": "20002",
"applicationName": "contosomaintenance",
"serviceName": "contosomaintenance-bot",
"endpointName": "http"
}
]
}
}
}
]
}
答案 0 :(得分:2)
更新2018-12-10
新的ApiVersion已发布(2018-09-01-preview),公开服务的新方法是使用网关资源。可以在this github线程和this文档上找到更多信息。
这是网关(仅)的片段,它公开了同一应用程序中的两个服务:
{
"apiVersion": "2018-09-01-preview",
"name": "helloWorldGateway",
"type": "Microsoft.ServiceFabricMesh/gateways",
"location": "[parameters('location')]",
"dependsOn": [
"Microsoft.ServiceFabricMesh/networks/helloWorldNetwork"
],
"properties": {
"description": "Service Fabric Mesh Gateway for HelloWorld sample.",
"sourceNetwork": {
"name": "Open"
},
"destinationNetwork": {
"name": "[resourceId('Microsoft.ServiceFabricMesh/networks', 'helloWorldNetwork')]"
},
"http": [
{
"name": "web",
"port": 81,
"hosts": [
{
"name": "*",
"routes": [
{
"name": "helloRoute",
"match": {
"path": {
"value": "/",
"rewrite": "/",
"type": "Prefix"
}
},
"destination": {
"applicationName": "helloWorldApp",
"serviceName": "helloWorldService",
"endpointName": "helloWorldListener"
}
}
]
}
]
},
{
"name": "kuard",
"port": 82,
"hosts": [
{
"name": "*",
"routes": [
{
"name": "kuardRoute",
"match": {
"path": {
"value": "/",
"rewrite": "/",
"type": "Prefix"
}
},
"destination": {
"applicationName": "helloWorldApp",
"serviceName": "kuardService",
"endpointName": "kuardListener"
}
}
]
}
]
}
],
"tcp": [
{
"name": "web",
"port": 80,
"destination": {
"applicationName": "helloWorldApp",
"serviceName": "helloWorldService",
"endpointName": "helloWorldListener"
}
},
{
"name": "kuard",
"port": 8080,
"destination": {
"applicationName": "helloWorldApp",
"serviceName": "kuardService",
"endpointName": "kuardListener"
}
}
]
}
}
注意:
原始答案
当前,网络有两个大限制:
这些是公开预览的限制,可能在GA上已解决。
在这种情况下,如果您需要公开两项服务,则可以选择以下替代方法: