-
Notifications
You must be signed in to change notification settings - Fork 1
GitHub Copilot Agent Mode
This doc is to write down the testing result of using GitHub Copilot Agent Mode, to analyze a Java project to generate the azure.yaml which describes the metadata of the project.
This doc will use the following target scenarios:
- Single project with Azure dependency
- Single project with non-Azure dependency (like MySQL or Kafka)
- Multiple projects with parent pom, with Azure dependency, and a project depends on other projects
- Multiple projects without parent pom, with Azure dependency, and a project depends on other projects
| Scenario | Testing Result | Used Project |
|---|---|---|
| Single project with Azure dependency | ✅ can detect resources, apps ❗️not good at binding envs | Java App Using Cosmos DB |
| Single project with non-Azure dependency (Kafka) | ✅ can detect resources, apps ❗️not good at binding envs | Java App Using Kafka |
| Single project with non-Azure dependency (MySQL) | ✅ can detect resources, apps | Java App Using Kafka |
| Multiple projects with parent pom, with Azure dependency, and a project depends on other projects | ❌ can detect resources, apps, and relationships | PetClinic Microservices |
| Multiple projects without parent pom, with Azure dependency, and a project depends on other projects | ✅ can detect resources, apps, but not relationships | Java backend + Vue Frontend |
- VS Code Insiders (Version: 1.97.0-insider), and GHCP Edit Agent Mode with Claude 3.5 Sonnet.
You are an expert on Java and Azure. I am asking you to analyze this project and generate an azure.yaml. This azure.yaml will describe this project.
The metadata includes:
- What language is this project written in?
- What services are used in this project (such as MySQL that can run on Azure, Azure services like Azure Cosmos DB or Azure Service Bus)?
- Which hosting platform to deploy this project (like Azure Container Apps, App Service)?
- Dependency information between the apps and the resources, like which app uses which resource, or which app is going to call other apps. The relationship should be defined under `uses`.
- Whether the application is a web application, if so, which port should be used and if not then it should not have any port specified.
- Which environment variables to set to the application that indicates the binding information between the app and the resource? If a Spring Cloud Azure library has been found, define the environment variables that is used in the Spring Cloud Azure library.
- If database resources are found being used in the application, please figure out the databases/tables/containers should be defined.
- If messaging resources like Service Bus and Event Hubs are found being used in the application, please figure out the topics/queues/subscriptions should be defined.
In this case, I want to deploy this project to Azure Container Apps together with resources that can be provisioned on Azure. Please ignore monitoring services for now.
An example of the azure.yaml would be like:
"""
name:
sample-app
services:
web:
project: ./../web/react-fluent
dist: dist
language: js
resources:
cosmos-db:
type: azure.cosmosdb
web:
type: azure.containerapps
uses:
- cosmos-db
"""
https://github.com/rujche/samples/tree/azd-enhancement-for-cosmos-db
The output azure.yaml can detect the app and resource:
name: spring-sample-app
services:
api:
language: java
project: .
host: containerapp
docker:
context: .
dockerfile: Dockerfile
bindings:
- port: 8080
env:
COSMOS_DATABASE: sample
# Spring Cloud Azure environment variables
AZURE_COSMOS_ENDPOINT: ${resources.cosmos.outputs.endpoint}
AZURE_COSMOS_DATABASE: ${resources.cosmos.outputs.database}
AZURE_COSMOS_KEY: ${resources.cosmos.outputs.key}
# Default Azure authentication variables
AZURE_CLIENT_ID: ${azure.credentials.clientId}
AZURE_TENANT_ID: ${azure.credentials.tenantId}
AZURE_CLIENT_SECRET: ${azure.credentials.clientSecret}
uses:
- cosmos
resources:
cosmos:
type: azure.cosmos
properties:
database: sample
containers:
- name: users
partitionKey: /lastNamehttps://github.com/haoozhang/Spring-Cloud-Stream-Kafka-Application
The output azure.yaml can detect the app and resource
name: spring-cloud-stream-kafka
services:
app:
language: java
project: .
docker:
context: .
dockerfile: Dockerfile
host: containerapp
env:
SPRING_CLOUD_STREAM_KAFKA_BINDER_BROKERS: ${eventhubs.properties.fqdn}:9093
SPRING_CLOUD_AZURE_EVENTHUBS_CONNECTION_STRING: ${eventhubs.connectionString}
resources:
eventhubs:
type: azure.eventhubs
properties:
kafka-enabled: true
topics:
- name: sample-topic
partitionCount: 1
containerapp:
type: azure.containerapps
properties:
cpu: 1
memory: 2Gi
targetPort: 8080
uses:
- eventhubsThe output azure.yaml can detect the resource:
name: spring-petclinic
services:
api:
project: .
language: java
docker:
context: .
dockerfile: Dockerfile
host: containerapp
resources:
mysql:
type: azure.mysql.flexibleserver
properties:
databases:
- name: petclinic
api:
type: azure.containerapps
properties:
ingress:
external: true
targetPort: 8080
env:
- name: SPRING_PROFILES_ACTIVE
value: mysql
- name: SPRING_DATASOURCE_URL
secretRef: mysql-connection-string
uses:
- mysqlhttps://github.com/azure-javaee/spring-petclinic-microservices/tree/sjad
The output of the azure.yaml is not accurate (for example the applicationinsights uses the other projects)
name: spring-petclinic-microservices
language: java
services:
admin-server:
project: ./spring-petclinic-admin-server
language: java
host: containerapp
api-gateway:
project: ./spring-petclinic-api-gateway
language: java
host: containerapp
config-server:
project: ./spring-petclinic-config-server
language: java
host: containerapp
customers-service:
project: ./spring-petclinic-customers-service
language: java
host: containerapp
discovery-server:
project: ./spring-petclinic-discovery-server
language: java
host: containerapp
vets-service:
project: ./spring-petclinic-vets-service
language: java
host: containerapp
visits-service:
project: ./spring-petclinic-visits-service
language: java
host: containerapp
resources:
mysql:
type: azure.mysql.flexible-server
uses:
- customers-service
- vets-service
- visits-service
redis:
type: azure.cache.redis
uses:
- vets-service
applicationinsights:
type: azure.monitor.application-insights
uses:
- admin-server
- api-gateway
- config-server
- customers-service
- discovery-server
- vets-service
- visits-servicehttps://github.com/rujche/todo-java-mongo-aca/tree/azd-enhancement-for-mongo
The output of the azure.yaml is accurate:
name: todo-java-mongo-aca
metadata:
template: todo-java-mongo-aca@0.0.1-beta
services:
api:
project: ./src/api
language: java
host: containerapp
docker:
context: ./src/api
dockerfile: Dockerfile
web:
project: ./src/web
language: js
host: containerapp
docker:
context: ./src/web
dockerfile: Dockerfile
resources:
database:
type: azure.cosmos.mongodb
properties:
databaseName: todo
keyvault:
type: azure.keyvault
applicationinsights:
type: azure.monitor.applicationinsights
api-container-app:
type: azure.containerapps
properties:
project: api
targetPort: 3100
uses:
- database
- keyvault
- applicationinsights
web-container-app:
type: azure.containerapps
properties:
project: web
uses:
- api-container-app
- applicationinsights