Azure API Management Self Hosted Gateway Automation

Rasmikant Bal 66 Reputation points
2023-01-17T12:14:55.98+00:00

I have API Management service with Self Hosted Gateway deployed in on Premise (RHEL OS) DOCKER to communicate with On Premise APIs.

  1. what's the best way automate copy the env.config file to on premise docker environment & execute following command ? docker run -d -p 80:8080 -p 443:8081 --name <gateway-name> --env-file env.conf mcr.microsoft.com/azure-api-management/gateway:<tag>
  2. The access token given for the self-hosted gateway is only valid for 30 days. How to regenerate the access token automatically for DOCKER ? Is it something we need do in Azure or something need to be done On Premise System. Which option is best ?
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,291 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MuthuKumaranMurugaachari-MSFT 22,401 Reputation points
    2023-01-25T12:02:21.7566667+00:00

    @Rasmikant Bal I assume you have already configured Docker, and APIs and looking for options to automate self-hosted gateway steps described in Deploy an Azure API Management self-hosted gateway to Docker. Unfortunately, we don't have any guidelines/doc or tools specifically on automating this process.

    My suggestion is to explore more on tools such as Azure Pipelines or GitHub Actions. Let's take Azure Pipelines as an example. I am not a DevOps expert and from the docs, I see you can Invoke REST API v1 task for calling Rest APIs and Docker v2 task for running docker command.

    To generate access token for Self-Hosted Gateway, first you need to set up App registration in Azure AD with client credential flow (refer doc), generate token from AD endpoint to access APIM endpoint and then call Gateway - Generate Token Rest API with AD token. Then depends on how docker container authentication/authorization is set up, you can manage access to Docker via pipeline and call Docker task to deploy self-hosted gateway.

    For any questions specific to DevOps, please feel free to reach out to dedicated forum [https://techcommunity.microsoft.com/t5/azure-devops/bd-p/AzureDevOpsForum (DevOps is not yet supported in Q&A) for assistance.

    Please let me know if I can help you with any other questions.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.