Skip to content

Instantly share code, notes, and snippets.

@saminitz
Last active February 7, 2024 13:20
Show Gist options
  • Save saminitz/33a307f40373b2d1618137468e1e6930 to your computer and use it in GitHub Desktop.
Save saminitz/33a307f40373b2d1618137468e1e6930 to your computer and use it in GitHub Desktop.
Deploy Eureka Client to Azure

Spring Boot

minimalistic application.yml:

spring:
  application:
    name: your-microservice-name
  profiles:
    active: ${SPRING_PROFILE}
eureka:
  client:
    serviceUrl:
      defaultZone: ${EUREKA_URI}
  instance:
    hostname: ${HOST_NAME}
management.endpoints.web.exposure.include: health,info

---
server:
  port: 80
spring:
  config:
    activate:
      on-profile: azure

Docker & Docker Hub

  1. Create or use a docker hub account to generate an Access Token for azure and cli login.
  2. Build a docker image with parameter --platform linux/amd64 and set a tag with following pattern: ?username/image_name:image_version eg.: docker build --platform linux/amd64 -t querslider/lending-service:latest-amd64 .
  3. Login to docker hub via docker login with your created Access Token for your cli.
  4. Push the docker container to your docker hub account eg.: docker push username/lending-service:latest-amd64
  5. Create a Azure Web App
    • Choose Docker Container
    • Click Next, not Review + Create
    • Go into the tab Docker
    • Set Options as Single Container
    • Set Image Source as Docker Hub
    • Set Access Type as Private
    • Set your username and set your generate Access Token as password
    • Set the image tag as username/image_name:image_version
    • Finish by creating the Web App
  6. Go to the created Web App into the Configuration and set the following environments variables
  • Set HOST_NAME to the Default Domain found at the Overview page of the Web App
  • Set WEBSITES_PORT to 80
  • Set all left variables used inside the application.yml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment