将服务结构配置为API管理后端

时间:2018-02-21 22:56:00

标签: azure azure-service-fabric azure-api-management

我开始探索将API管理服务与服务架构后端集成,但我无法让它发挥作用。

我有一个简单的应用程序部署到一个群集,它暴露了一个无状态服务。我尝试使用我能找到的几个例子来配置API管理,例如:

https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-api-management-overview

但是我收到一个错误,告诉我无论我输入什么都无法找到给定的后端ID。

我已阅读对此问题的回复,其中说明我需要设置后端资源: API Management vs. Service Flow

...链接到本教程中的模板: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-tutorial-deploy-api-management

并试图提取'后端'部分但仍无法使其发挥作用。有没有人有一个简单的示例或如何设置后端资源的说明,以便我可以设置指向集群中运行的服务结构服务的set-backend-service入站规则?

由于

3 个答案:

答案 0 :(得分:0)

PUT https://management.azure.com/subscriptions/subid/resourceGroups/rg1/providers/Microsoft.ApiManagement/service/apimService1/backends/sfbackend?api-version=2017-03-01

{
  "properties": {
    "description": "Service Fabric Test App 1",
    "protocol": "http",
    "url": "fabric:/mytestapp/mytestservice",
    "properties": {
      "serviceFabricCluster": {
        "managementEndpoints": [
          "https://somecluster.com"
        ],
        "clientCertificatethumbprint": "EBA029198AA3E76EF0D70482626E5BCF148594A6",
        "serverX509Names": [
          {
            "name": "ServerCommonName1",
            "issuerCertificateThumbprint": "IssuerCertificateThumbprint1"
          }
        ],
        "maxPartitionResolutionRetries": 5
      }
    }
  }
}

来自https://docs.microsoft.com/en-us/rest/api/apimanagement/backend/createorupdate#apimanagementcreatebackendservicefabric

答案 1 :(得分:0)

似乎通过ARM模板创建后端是使其工作的最佳方法,但是可以尝试使用专门在API管理中创建SF后端的命令:new-AzureRmApiManagementBackendServiceFabric

https://docs.microsoft.com/en-us/powershell/module/azurerm.apimanagement/new-azurermapimanagementbackendservicefabric

我这样做了,但是遇到了另一个阻止程序:UI拒绝接受在命令中创建的BackendID。它说,即使考虑到命令get-AzureRmApiManagementBackend显示最近创建的ID,该ID也是无效的。

答案 2 :(得分:0)

我知道这有点老了,我通过以下方式解决了该问题:

try {
    const res = await DocumentPicker.pick({
        type: [DocumentPicker.types.images],
    });

    console.log(res) //not showing anything

    if (res.size <= 3145728) {// 3 MB 
        dispatch({
        type: ACTION_TYPE_PICK_PHOTO_PROFILE_SUCCESS,
        payload: res,
    });
    } else {
    dispatch({
        type: ACTION_TYPE_PICK_PHOTO_PROFILE_EXCEED,
        payload: res
    });
    }
} catch (err) {
    console.log(err) //not showing anything

    if (DocumentPicker.isCancel(err)) {
    // User cancelled the picker, exit any dialogs or menus and move on
    }
}

然后将Api和下面的入站标记放在下面:

$apimContext = New-AzureRmApiManagementContext -ResourceGroupName "resourcegroupname" -ServiceName "ApiManagementServicename"
$ManagementEndpoints = 'https://xxxxx:19000'
$ServerCertificateThumbprints = 'thumbprint'
$serviceFabric = New-AzureRmApiManagementBackendServiceFabric -ManagementEndpoint $ManagementEndpoints -ClientCertificateThumbprint $ServerCertificateThumbprints -ServerCertificateThumbprint $ServerCertificateThumbprints
$backend = New-AzureRmApiManagementBackend -Context $apimContext -BackendId SFBackEnd -Url 'fabric:/App/Service' -Protocol http -ServiceFabricCluster $serviceFabric -Description "service fabric backend"

确保命令“ New-AzureRmApiManagementBackend”中的网址与“ sf-service-instance-name”相同

欢呼