0
votes

I'm starting to explore integrating an API management service with a service fabric backend but I can't get it to work.

I have a simple app deployed to a cluster which is exposing one stateless service. I'm trying to configure API management using the few examples I can find, e.g:

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

But I get an error telling me that the given backend-id cannot be found, no matter what I enter.

I have read the response to this question where it's stated that I need to setup a backend resource: API Management vs. Service Flow

...which links to the template from this tutorial: https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-tutorial-deploy-api-management

And have tried to extract the 'backends' part but still can't get it to work. Does anyone have a simple example or instructions of how I can setup a backend resource so that i can setup a set-backend-service inbound rule pointing to my service fabric service running in a cluster?

Thanks

3

3 Answers

0
votes

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
      }
    }
  }
}

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

0
votes

It seems that creating the backend through ARM templates is the best way to make it work, but give it a try to a command made specifically to create SF Backends in API Management: new-AzureRmApiManagementBackendServiceFabric

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

I did, but ran into another blocker: the UI refuses to accept the BackendID created in the command. It says the ID is invalid, even considering that the command get-AzureRmApiManagementBackend shows the recently created IDs.

0
votes

I know this is bit old, I resolved it as following:

$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"

Then go the Api and under inbound tag put following:

<set-backend-service backend-id="SFBackEnd" sf-service-instance-name="fabric:/App/Service" />

make sure the url in command "New-AzureRmApiManagementBackend" is same as "sf-service-instance-name"

Cheers