From 5f4b1ee90f241ba785659181a89a58ca971bbb97 Mon Sep 17 00:00:00 2001 From: Songbo Wang Date: Thu, 26 Sep 2024 16:10:26 +0800 Subject: [PATCH] some minor improvements (#61) ## Purpose 1. add springbootadmin binding to eureka 2. fix default placeholder image tag 3. refine the azd up steps ## Does this introduce a breaking change? ``` [ ] Yes [x] No ``` ## Pull Request Type What kind of change does this Pull Request introduce? ``` [x] Bugfix [x] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Documentation content changes [ ] Other... Please describe: ``` --- azure.yaml | 30 +++++++++++-------- docs/06_lab_automation/0601.md | 2 +- docs/06_lab_automation/0602.md | 9 ++++-- infra/bicep/main.bicep | 4 ++- .../containerapp-java-components.bicep | 15 ++++++++++ 5 files changed, 42 insertions(+), 18 deletions(-) diff --git a/azure.yaml b/azure.yaml index 866d4d6..0722a6e 100644 --- a/azure.yaml +++ b/azure.yaml @@ -1,6 +1,13 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json name: java-microservices-aca-lab + +workflows: + up: + - azd: provision + - azd: package --all + - azd: deploy --all + infra: provider: bicep path: infra/bicep @@ -12,7 +19,7 @@ services: host: containerapp language: java docker: - registry: .azurecr.io + registry: .azurecr.io image: java-microservices-aca-lab/spring-petclinic-api-gateway tag: passwordless @@ -22,7 +29,7 @@ services: host: containerapp language: java docker: - registry: .azurecr.io + registry: .azurecr.io image: java-microservices-aca-lab/spring-petclinic-customers-service tag: passwordless @@ -32,7 +39,7 @@ services: host: containerapp language: java docker: - registry: .azurecr.io + registry: .azurecr.io image: java-microservices-aca-lab/spring-petclinic-vets-service tag: passwordless @@ -42,7 +49,7 @@ services: host: containerapp language: java docker: - registry: .azurecr.io + registry: .azurecr.io image: java-microservices-aca-lab/spring-petclinic-visits-service tag: passwordless @@ -52,7 +59,7 @@ services: host: containerapp language: java docker: - registry: .azurecr.io + registry: .azurecr.io image: java-microservices-aca-lab/spring-petclinic-chat-agent tag: passwordless @@ -62,20 +69,17 @@ services: host: containerapp language: java docker: - registry: .azurecr.io + registry: .azurecr.io image: java-microservices-aca-lab/spring-petclinic-admin-server tag: passwordless hooks: - prepackage: - windows: - shell: pwsh - run: 'cd src; .\mvnw.cmd clean package -DskipTests' + postprovision: posix: shell: sh - run: 'cd src; chmod +x ./mvnw; ./mvnw clean package -DskipTests' + run: ./infra/bicep/hooks/postprovision.sh - postprovision: + prepackage: posix: shell: sh - run: ./infra/bicep/hooks/postprovision.sh + run: 'cd src; chmod +x ./mvnw; ./mvnw clean package -DskipTests' diff --git a/docs/06_lab_automation/0601.md b/docs/06_lab_automation/0601.md index 16b33cd..766f2b7 100644 --- a/docs/06_lab_automation/0601.md +++ b/docs/06_lab_automation/0601.md @@ -30,7 +30,7 @@ Prepare your local environment and plan your Azure resource, get ready for the o - Option 1: Create a new Azure Container Registry ```bash - ACR_RESOURCE_GROUP= + ACR_RESOURCE_GROUP= ACR_NAME= az acr create \ -n $ACR_NAME \ diff --git a/docs/06_lab_automation/0602.md b/docs/06_lab_automation/0602.md index de3f97a..e478f00 100644 --- a/docs/06_lab_automation/0602.md +++ b/docs/06_lab_automation/0602.md @@ -32,11 +32,14 @@ Run `azd up` to deploy the petclinic solution and dependent components to Azure If you meet any problems during this step, refer to page [Triage the issues](0603.md) -1. Run `azd show` +1. Run `azd env get-values` You may see lots of variables from the results. Open the urls to your deployed service: ```text - gatewayFqdn="api-gateway...azurecontainerapps.io" - adminFqdn="admin-server...azurecontainerapps.io" + API gateway: gatewayFqdn="api-gateway...azurecontainerapps.io" + Admin Server: adminFqdn="admin-server...azurecontainerapps.io" + Spring Boot Admin: springbootAdminFqdn="springbootadmin-azure-java.ext...azurecontainerapps.io" ``` + + Visit the urls to check the status of the services. diff --git a/infra/bicep/main.bicep b/infra/bicep/main.bicep index a016234..04dfb43 100644 --- a/infra/bicep/main.bicep +++ b/infra/bicep/main.bicep @@ -76,7 +76,7 @@ var vnetPrefix = '10.1.0.0/16' var infraSubnetPrefix = '10.1.0.0/24' var infraSubnetName = '${abbrs.networkVirtualNetworksSubnets}infra' -var placeholderImage = 'azurespringapps/default-banner:distroless-2024022107-66ea1a62-87936983' +var placeholderImage = 'azurespringapps/default-banner:latest' var abbrs = loadJsonContent('./abbreviations.json') var tags = { 'azd-env-name': environmentName } @@ -139,6 +139,7 @@ module mysql 'modules/database/mysql.bicep' = { administratorLoginPassword: sqlAdminPassword serverName: !empty(sqlServerName) ? sqlServerName : '${abbrs.sqlServers}${environmentName}' databaseName: 'petclinic' + tags: tags } } @@ -266,6 +267,7 @@ module applications 'modules/app/petclinic.bicep' = { output resourceGroupName string = rg.name +output springbootAdminFqdn string = javaComponents.outputs.springbootAdminFqdn output gatewayFqdn string = applications.outputs.gatewayFqdn output adminFqdn string = applications.outputs.adminFqdn diff --git a/infra/bicep/modules/containerapps/containerapp-java-components.bicep b/infra/bicep/modules/containerapps/containerapp-java-components.bicep index bb83cc6..c39445d 100644 --- a/infra/bicep/modules/containerapps/containerapp-java-components.bicep +++ b/infra/bicep/modules/containerapps/containerapp-java-components.bicep @@ -25,11 +25,18 @@ resource configServer 'Microsoft.App/managedEnvironments/javaComponents@2024-02- propertyName: 'spring.cloud.config.server.git.search-paths' value: configServerGitPath } + { + propertyName: 'spring.cloud.config.server.git.refresh-rate' + value: '60' + } ] } } resource eureka 'Microsoft.App/managedEnvironments/javaComponents@2024-02-02-preview' = { + dependsOn: [ + configServer + ] parent: managedEnvironmentsResource name: 'eureka' properties: { @@ -48,8 +55,16 @@ resource springbootadmin 'Microsoft.App/managedEnvironments/javaComponents@2024- name: 'springbootadmin' properties: { componentType: 'SpringBootAdmin' + serviceBinds: [ + { + name: eureka.name + serviceId: eureka.id + } + ] } } output eurekaId string = eureka.id output configServerId string = configServer.id + +output springbootAdminFqdn string = springbootadmin.properties.ingress.fqdn