Open Closed

Error routing for the APIs using Azure API Management #5246


User avatar
0
nvc_abp_dev1 created
  • ABP Framework version: v7.2.2
  • UI type: Angular
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Identity server separated

Hi,

I'd like to know if there is a guide to replace the Ocelot gateway to the Azure API Management.

I am having an issue regarding the routing for the APIs. When we log in, and the system tries to get the required permissions, roles, etc. It throws an error because the routing tries to get the data only fromthe apis like: "api/identity/..." after default endpoint (authserver.com/...), but for Azure API Management we need to configure a suffix for all the APIs, ex. For IdentityService the right URL is "https://apim_route/identityservice/api/identity/..." and the suffix configured is "identityservice", but when we do a request it does the following: "https://apim_route/api/identity/...".

We tried to modify the API routes following the same pattern for new services and checking the JSON for APIs configuration mentioned here in the environment file in this way :

import { Environment } from '@abp/ng.core';

const baseUrl = 'https://flyguys-spa-dev-cus.azurewebsites.net';

const oAuthConfig = {
  issuer: 'https://flyguys-authserver-dev-cus.azurewebsites.net/',
  clientId: 'Angular',
  scope:
    'offline_access openid profile email phone AccountService IdentityService AdministrationService SaasService ProductService CoreService FileManagementService',
  requireHttps: true
};

export const environment = {
  production: false,
  application: {
    baseUrl,
    name: 'Flyguys',
  },
  oAuthConfig,
  apis: {
    default: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net',
      rootNamespace: 'NVC.Flyguys',
    },
    AbpAccountPublic: {
      url: oAuthConfig.issuer,
      rootNamespace: 'AbpAccountPublic',
    },
    ProductService: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/productservice',
      rootNamespace: 'NVC.Flyguys.ProductService'
    },
    AbpIdentity: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/identityservice',
      rootNamespace: 'AbpIdentity'
    },
    AbpAuditLogging: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/administrationservice',
      rootNamespace: 'AbpAuditLogging'
    },
    TextTemplateManagement: {
      url: "https://flyguys-apim-dev-eus.azure-api.net/administrationservice",
      rootNamespace: 'TextTemplateManagement'
    },
    LanguageManagement: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/administrationservice',
      rootNamespace: 'LanguageManagement'
    },
    AbpPermissionManagement: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/administrationservice',
      rootNamespace: 'AbpPermissionManagement'
    },
    SettingManagement: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/administrationservice',
      rootNamespace: 'SettingManagement'
    },
    AbpAccountAdmin: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/identityservice',
      rootNamespace: 'AbpAccountAdmin'
    },
    AbpPaymentCommon: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/saasservice',
      rootNamespace: 'AbpPaymentCommon'
    },
    SaasHost: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/saasservice',
      rootNamespace: 'SaasHost'
    },
    AbpFeatureManagement: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/saasservice',
      rootNamespace: 'AbpFeatureManagement'
    },
    CoreService: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/coreservice',
      rootNamespace: 'NVC.Flyguys.CoreService'
    },
    FileManagement: {
      url: 'https://flyguys-apim-dev-eus.azure-api.net/mediastorageservice',
      rootNamespace: 'NVC.Flyguys.FileManagementService'
    }
  },
} as Environment;

Could you help us with this approach, please?


3 Answer(s)
  • User Avatar
    0
    gterdem created
    Senior .NET Developer
    apis: {
        default: {
          url: 'https://flyguys-apim-dev-eus.azure-api.net', // Should be the API gateway
          rootNamespace: 'NVC.Flyguys',
        },
    

    The default api should be the gateway. Others used for generating the static proxies. Try these steps:

    1. Check if the static proxies are generated correctly.
    2. Follow the request log to the gateway if the gateway receives the request.
    3. If the gateway receives the request but can not find the downstream; you should configure the downstreams with the suffix as how it can find.
    4. If the gateway doesn't receive the request, check the default route and the static proxy generation again.
  • User Avatar
    0
    nvc_abp_dev1 created

    We are using our gateway, in this case Azure API Management. We configured it with all services and we want to use it as Gateway.

    we have some questions:

    1. What do you mean with the comment "// Should be the API gateway"? should it be the project with ocelot?
    2. Could you be more specific with the steps? (how can we do it, the steps for do it, etc.)
    3. Our idea is remove ocelot, can we replace for our API Management configuration?

    Thanks in advance

  • User Avatar
    0
    gterdem created
    Senior .NET Developer

    I am not familiar with Azure API Management, however you need to use a gateway instead of ocelot in your case. I don't exactly know which product Azure provides for this functionality; not even sure if it provides even.

    1. It should be the gateway you have deployed with a valid DNS on a server, doesn't matter ocelot, krakend, envoy or related Azure API product.
    2. When you make a request from your web application, check the logs of the gateway if it receives it.
    3. Yes you can replace ocelot. I don't know about Azure API Management, you will need to check for other samples related to that.
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11