Skip to content

Commit

Permalink
Support azd (#62)
Browse files Browse the repository at this point in the history
* remove kv and use env var

* add readme

* change mysql to h2

* remove outdated content
  • Loading branch information
yiliuTo committed Jul 18, 2023
1 parent f289400 commit 13118ca
Show file tree
Hide file tree
Showing 8 changed files with 587 additions and 117 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,6 @@ generated/


setup-env-variables-azure.sh

# AZD
.azure
243 changes: 127 additions & 116 deletions README.md

Large diffs are not rendered by default.

49 changes: 49 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/alpha/azure.yaml.json

name: spring-petclinic-microservices
metadata:
template: [email protected]
hooks:
preprovision:
posix:
shell: sh
run: ./mvnw clean install -N
windows:
shell: pwsh
run: ./mvnw.cmd clean install -N
services:
api-gateway:
project: ./spring-petclinic-api-gateway
host: springapp
language: java
resourceName: ${ASA_INSTANCE_NAME}
spring:
deploymentName: default
admin-server:
project: ./spring-petclinic-admin-server
host: springapp
language: java
resourceName: ${ASA_INSTANCE_NAME}
spring:
deploymentName: default
customers-service:
project: ./spring-petclinic-customers-service
host: springapp
language: java
resourceName: ${ASA_INSTANCE_NAME}
spring:
deploymentName: default
vets-service:
project: ./spring-petclinic-vets-service
host: springapp
language: java
resourceName: ${ASA_INSTANCE_NAME}
spring:
deploymentName: default
visits-service:
project: ./spring-petclinic-visits-service
host: springapp
language: java
resourceName: ${ASA_INSTANCE_NAME}
spring:
deploymentName: default
137 changes: 137 additions & 0 deletions infra/abbreviations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"analysisServicesServers": "as",
"apiManagementService": "apim-",
"appConfigurationConfigurationStores": "appcs-",
"appManagedEnvironments": "cae-",
"appContainerApps": "ca-",
"authorizationPolicyDefinitions": "policy-",
"automationAutomationAccounts": "aa-",
"blueprintBlueprints": "bp-",
"blueprintBlueprintsArtifacts": "bpa-",
"cacheRedis": "redis-",
"cdnProfiles": "cdnp-",
"cdnProfilesEndpoints": "cdne-",
"cognitiveServicesAccounts": "cog-",
"cognitiveServicesFormRecognizer": "cog-fr-",
"cognitiveServicesTextAnalytics": "cog-ta-",
"computeAvailabilitySets": "avail-",
"computeCloudServices": "cld-",
"computeDiskEncryptionSets": "des",
"computeDisks": "disk",
"computeDisksOs": "osdisk",
"computeGalleries": "gal",
"computeSnapshots": "snap-",
"computeVirtualMachines": "vm",
"computeVirtualMachineScaleSets": "vmss-",
"containerInstanceContainerGroups": "ci",
"containerRegistryRegistries": "cr",
"containerServiceManagedClusters": "aks-",
"databricksWorkspaces": "dbw-",
"dataFactoryFactories": "adf-",
"dataLakeAnalyticsAccounts": "dla",
"dataLakeStoreAccounts": "dls",
"dataMigrationServices": "dms-",
"dBforMySQLServers": "mysql-",
"dBforPostgreSQLServers": "psql-",
"devicesIotHubs": "iot-",
"devicesProvisioningServices": "provs-",
"devicesProvisioningServicesCertificates": "pcert-",
"documentDBDatabaseAccounts": "cosmos-",
"eventGridDomains": "evgd-",
"eventGridDomainsTopics": "evgt-",
"eventGridEventSubscriptions": "evgs-",
"eventHubNamespaces": "evhns-",
"eventHubNamespacesEventHubs": "evh-",
"hdInsightClustersHadoop": "hadoop-",
"hdInsightClustersHbase": "hbase-",
"hdInsightClustersKafka": "kafka-",
"hdInsightClustersMl": "mls-",
"hdInsightClustersSpark": "spark-",
"hdInsightClustersStorm": "storm-",
"hybridComputeMachines": "arcs-",
"insightsActionGroups": "ag-",
"insightsComponents": "appi-",
"keyVaultVaults": "kv-",
"kubernetesConnectedClusters": "arck",
"kustoClusters": "dec",
"kustoClustersDatabases": "dedb",
"logicIntegrationAccounts": "ia-",
"logicWorkflows": "logic-",
"machineLearningServicesWorkspaces": "mlw-",
"managedIdentityUserAssignedIdentities": "id-",
"managementManagementGroups": "mg-",
"migrateAssessmentProjects": "migr-",
"networkApplicationGateways": "agw-",
"networkApplicationSecurityGroups": "asg-",
"networkAzureFirewalls": "afw-",
"networkBastionHosts": "bas-",
"networkConnections": "con-",
"networkDnsZones": "dnsz-",
"networkExpressRouteCircuits": "erc-",
"networkFirewallPolicies": "afwp-",
"networkFirewallPoliciesWebApplication": "waf",
"networkFirewallPoliciesRuleGroups": "wafrg",
"networkFrontDoors": "fd-",
"networkFrontdoorWebApplicationFirewallPolicies": "fdfp-",
"networkLoadBalancersExternal": "lbe-",
"networkLoadBalancersInternal": "lbi-",
"networkLoadBalancersInboundNatRules": "rule-",
"networkLocalNetworkGateways": "lgw-",
"networkNatGateways": "ng-",
"networkNetworkInterfaces": "nic-",
"networkNetworkSecurityGroups": "nsg-",
"networkNetworkSecurityGroupsSecurityRules": "nsgsr-",
"networkNetworkWatchers": "nw-",
"networkPrivateDnsZones": "pdnsz-",
"networkPrivateLinkServices": "pl-",
"networkPublicIPAddresses": "pip-",
"networkPublicIPPrefixes": "ippre-",
"networkRouteFilters": "rf-",
"networkRouteTables": "rt-",
"networkRouteTablesRoutes": "udr-",
"networkTrafficManagerProfiles": "traf-",
"networkVirtualNetworkGateways": "vgw-",
"networkVirtualNetworks": "vnet-",
"networkVirtualNetworksSubnets": "snet-",
"networkVirtualNetworksVirtualNetworkPeerings": "peer-",
"networkVirtualWans": "vwan-",
"networkVpnGateways": "vpng-",
"networkVpnGatewaysVpnConnections": "vcn-",
"networkVpnGatewaysVpnSites": "vst-",
"notificationHubsNamespaces": "ntfns-",
"notificationHubsNamespacesNotificationHubs": "ntf-",
"operationalInsightsWorkspaces": "log-",
"portalDashboards": "dash-",
"powerBIDedicatedCapacities": "pbi-",
"purviewAccounts": "pview-",
"postgresServer": "pg-",
"recoveryServicesVaults": "rsv-",
"resourcesResourceGroups": "rg-",
"searchSearchServices": "srch-",
"serviceBusNamespaces": "sb-",
"serviceBusNamespacesQueues": "sbq-",
"serviceBusNamespacesTopics": "sbt-",
"serviceEndPointPolicies": "se-",
"serviceFabricClusters": "sf-",
"signalRServiceSignalR": "sigr",
"springApps": "asa-",
"sqlManagedInstances": "sqlmi-",
"sqlServers": "sql-",
"sqlServersDataWarehouse": "sqldw-",
"sqlServersDatabases": "sqldb-",
"sqlServersDatabasesStretch": "sqlstrdb-",
"storageStorageAccounts": "st",
"storageStorageAccountsVm": "stvm",
"storSimpleManagers": "ssimp",
"streamAnalyticsCluster": "asa-",
"synapseWorkspaces": "syn",
"synapseWorkspacesAnalyticsWorkspaces": "synw",
"synapseWorkspacesSqlPoolsDedicated": "syndp",
"synapseWorkspacesSqlPoolsSpark": "synsp",
"timeSeriesInsightsEnvironments": "tsi-",
"webServerFarms": "plan-",
"webSitesAppService": "app-",
"webSitesAppServiceEnvironment": "ase-",
"webSitesFunctions": "func-",
"webStaticSites": "stapp-"
}
67 changes: 67 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
targetScope = 'subscription'

@minLength(1)
@maxLength(64)
@description('Name of the the environment which is used to generate a short unique hash used in all resources.')
param environmentName string

@minLength(1)
@description('Primary location for all resources')
param location string

@description('Relative Path of ASA API gateway app Jar')
param gatewayRelativePath string

@description('Relative Path of ASA admin server app Jar')
param adminRelativePath string

@description('Relative Path of ASA customers service app Jar')
param customersRelativePath string

@description('Relative Path of ASA vets service app Jar')
param vetsRelativePath string

@description('Relative Path of ASA visits service app Jar')
param visitsRelativePath string

var abbrs = loadJsonContent('./abbreviations.json')
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location))
var asaInstanceName = '${abbrs.springApps}${resourceToken}'
var gatewayAppName = 'api-gateway'
var adminAppName = 'admin-server'
var customersAppName = 'customers-service'
var vetsAppName = 'vets-service'
var visitsAppName = 'visits-service'
var tags = {
'azd-env-name': environmentName
'spring-cloud-azure': 'true'
}

// Organize resources in a resource group
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
name: '${abbrs.resourcesResourceGroups}${environmentName}'
location: location
tags: tags
}

module springApps 'modules/springapps/springapps.bicep' = {
name: '${deployment().name}--asa'
scope: resourceGroup(rg.name)
params: {
location: location
gatewayAppName: gatewayAppName
adminAppName: adminAppName
customersAppName: customersAppName
vetsAppName: vetsAppName
visitsAppName: visitsAppName
tags: tags
asaInstanceName: asaInstanceName
gatewayRelativePath: gatewayRelativePath
adminRelativePath: adminRelativePath
customersRelativePath: customersRelativePath
vetsRelativePath: vetsRelativePath
visitsRelativePath: visitsRelativePath
}
}

output ASA_INSTANCE_NAME string = '${asaInstanceName}'
27 changes: 27 additions & 0 deletions infra/main.parameters.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"environmentName": {
"value": "${AZURE_ENV_NAME}"
},
"location": {
"value": "${AZURE_LOCATION}"
},
"gatewayRelativePath": {
"value": "${SERVICE_SPRING_PETCLINIC_API_GATEWAY_RELATIVE_PATH=<default>}"
},
"adminRelativePath": {
"value": "${SERVICE_SPRING_PETCLINIC_ADMIN_SERVER_RELATIVE_PATH=<default>}"
},
"customersRelativePath": {
"value": "${SERVICE_SPRING_PETCLINIC_CUSTOMERS_RELATIVE_PATH=<default>}"
},
"vetsRelativePath": {
"value": "${SERVICE_SPRING_PETCLINIC_VETS_RELATIVE_PATH=<default>}"
},
"visitsRelativePath": {
"value": "${SERVICE_SPRING_PETCLINIC_VISITS_RELATIVE_PATH=<default>}"
}
}
}
Loading

0 comments on commit 13118ca

Please sign in to comment.