Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/sjad #4473

Draft
wants to merge 170 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
849de05
Add a new child action "orchestrate". And create a sample azure.yaml …
rujche Sep 6, 2024
acee60b
Get list of pom files.
rujche Sep 9, 2024
88d4d1b
add the code for azd java analyzer
saragluna Sep 10, 2024
6ba0816
Hook the java analyzer with the azd init.
saragluna Sep 11, 2024
6a4b664
Enhance
saragluna Sep 11, 2024
bafcbc4
Implement java_project_bicep_file_generator.go.
rujche Sep 11, 2024
b69a47e
Improve log: Add information about the file path.
rujche Sep 11, 2024
69bc59a
Enhance the java analyzer
saragluna Sep 13, 2024
8d67fc5
Add feature: Support add mysql when run "azd init".
rujche Sep 13, 2024
91900aa
Delete java_project_bicep_file_generator.go.
rujche Sep 13, 2024
2da438b
Add logic about accessing mysql in aca.
rujche Sep 14, 2024
f4e00ef
Merge pull request #1 from rujche/rujche/java-analyzer
saragluna Sep 14, 2024
2aa6cac
Fix typo by changing "DbMysql" to "DbMySql".
rujche Sep 14, 2024
cace7fa
Merge pull request #2 from rujche/rujche/java-analyzer
saragluna Sep 14, 2024
082b9b2
Use managed-identity instead of username and password. Now it has err…
rujche Sep 18, 2024
b0c39a6
Access MySql by managed identity instead of username&password.
rujche Sep 20, 2024
f90416f
Add Azure Deps in appdetect.go
saragluna Sep 23, 2024
84b7852
Customize the azd VS Code extension
saragluna Sep 23, 2024
6587f83
improve the java analyzer for event-driven
saragluna Sep 23, 2024
103a005
refactor the java analyzer
saragluna Sep 26, 2024
2e01347
Create service connector by bicep file.
rujche Sep 27, 2024
708681a
1. Remove duplicated 'azd extension add'.
rujche Sep 29, 2024
353a802
Update name of resources: linkerCreatorIdentity and appLinkToMySql
rujche Sep 29, 2024
6d853de
Merge remote-tracking branch 'saragluna/java-analyzer' into rujche/ja…
rujche Sep 29, 2024
85ec20b
Merge pull request #3 from rujche/rujche/java-analyzer
saragluna Sep 29, 2024
2856fb9
Merge remote-tracking branch 'saragluna/java-analyzer' into rujche/ja…
rujche Sep 29, 2024
b70878e
1. Add rule about postgresql in project_analyzer_java.go.
rujche Oct 7, 2024
437eeb6
Fix the error about CORS.
rujche Oct 7, 2024
3410c97
Merge pull request #4 from rujche/rujche/java-analyzer
saragluna Oct 8, 2024
f244293
Merge branch 'main' into saragluna/java-analyzer
rujche Oct 8, 2024
df2f5f2
add support for service bus
saragluna Oct 8, 2024
b6e6ecc
fix servicebus
saragluna Oct 8, 2024
073d857
Remove the logic of create tag after create service connector.
rujche Oct 8, 2024
ef73ce1
Merge remote-tracking branch 'saragluna/java-analyzer' into rujche/ja…
rujche Oct 8, 2024
4c84661
Merge pull request #5 from rujche/rujche/java-analyzer
rujche Oct 8, 2024
f1e2fc1
support both mi and connection string for service bus
saragluna Oct 9, 2024
23362f8
For PostgreSQL, support both password and passwordless.
rujche Oct 10, 2024
193f054
For MySQL, support both password and passwordless.
rujche Oct 11, 2024
48cbeb5
Remove logic of adding tag after creating service connector. Because …
rujche Oct 11, 2024
9f4fe27
Fix bug: create service connector only work for the first time run of…
rujche Oct 11, 2024
207ffa3
Merge pull request #6 from rujche/rujche/java-analyzer
rujche Oct 12, 2024
0594412
Add new feature: analyze project to add Mongo DB.
rujche Oct 12, 2024
c45382a
Delete unused content in main.bicept.
rujche Oct 12, 2024
dca325f
Merge pull request #7 from rujche/rujche/java-analyzer
rujche Oct 12, 2024
babf604
Fix bug: Get auth type should only be required for MySQL and PostgreSQL.
rujche Oct 14, 2024
12b169e
Merge pull request #8 from rujche/rujche/java-analyzer
rujche Oct 14, 2024
a2a3a73
Make sure app work well after deployed to ACA no matter what value "s…
rujche Oct 15, 2024
2f4d2e9
Merge pull request #9 from rujche/rujche/java-analyzer
rujche Oct 15, 2024
a83f7d7
Implement feature: detect port in Dockerfile.
rujche Oct 15, 2024
35f762c
Merge pull request #10 from rujche/rujche/java-analyzer
rujche Oct 15, 2024
de2e922
Implement feature: detect redis by analyzing pom file.
rujche Oct 15, 2024
8607043
Merge pull request #11 from rujche/rujche/java-analyzer
rujche Oct 15, 2024
a482496
Detect Mongo DB by dependency spring-boot-starter-data-mongodb-reacti…
rujche Oct 15, 2024
671902a
Merge pull request #12 from rujche/rujche/java-analyzer
rujche Oct 15, 2024
9c53e73
Support all kinds of properties file like application(-profile).yaml(…
rujche Oct 16, 2024
6e14a1b
Merge pull request #13 from rujche/rujche/java-analyzer
rujche Oct 16, 2024
6c117ee
Merge the java analyzer code from the main branch to sjad (#1)
saragluna Oct 22, 2024
ea4083f
Merge branch 'main' into feature/sjad
saragluna Oct 24, 2024
b44c961
Merge branch 'main' into feature/sjad
saragluna Oct 25, 2024
f8a10da
remove the orchestrate command (#2)
saragluna Oct 25, 2024
a6e2da5
fix ut
saragluna Oct 28, 2024
d1cd151
fix ut
saragluna Oct 29, 2024
a8f91b1
Support detecting event hubs by analyzing pom.xml and application.yml…
rujche Oct 29, 2024
d992c70
Support detect Azure Event Hubs - 2 (#6)
rujche Oct 30, 2024
ef8ebe2
switch to service bus avm (#7)
saragluna Oct 30, 2024
39fda8c
Support detect Azure Event Hubs, connect by connection string. (#8)
rujche Nov 1, 2024
2a21115
Use to AVM to support PostgreSql (#9)
rujche Nov 4, 2024
65cbfe1
Add a span to indicate if java detector has started or finished (#10)
haoozhang Nov 4, 2024
030ec5b
Use to AVM to support MySql: Auth by managed identity and username & …
rujche Nov 5, 2024
41331c0
output resources from app init (#4)
saragluna Nov 5, 2024
73810a1
Merge branch 'main' into feature/sjad
saragluna Nov 5, 2024
b5069e5
update azure yaml schema to support `resources` (#12)
haoozhang Nov 5, 2024
31f8240
Update azure.yaml schema reference for private preview (#13)
haoozhang Nov 6, 2024
08e3776
Support this scenario: frontend + backend + MongoDB (#14)
rujche Nov 11, 2024
209e859
Azd enhancement for cosmosdb (#15)
rujche Nov 11, 2024
eb356d4
Auto-detecting Redis in spring boot applications. (#16)
rujche Nov 11, 2024
0d66981
Merge branch 'main' into feature/sjad
saragluna Nov 11, 2024
9bdd8d6
fix ut
saragluna Nov 11, 2024
9ba423a
Delete service names because they are not used. (#17)
rujche Nov 12, 2024
e161608
Add support for Service Bus JMS (#19)
saragluna Nov 12, 2024
efd325d
Only provide "SPRING_DATASOURCE_URL" environment variable when using …
rujche Nov 12, 2024
5ee0aa0
Support detecting Kafka by analyzing pom.xml and application.yml (#18)
haoozhang Nov 12, 2024
18a7cbc
Change all spring related environment variable to lower-case-with-das…
rujche Nov 12, 2024
f70b046
Output the resources to azure.yaml when enable compose mode (#22)
saragluna Nov 13, 2024
d6b8040
convert resources to infraspec (#23)
saragluna Nov 13, 2024
6ed094e
Fix error when run azd init (#24)
rujche Nov 14, 2024
f05aa04
Merge branch 'main' into feature/sjad
saragluna Nov 14, 2024
2e14836
Fix error that ".DbMySql" not take effect in resources.bicept. (#25)
rujche Nov 14, 2024
3b33dc6
Fix error about marshal yaml (#26)
rujche Nov 15, 2024
a0b3d6b
Prompt when Kafka detected but no spring-cloud-azure dependency found…
haoozhang Nov 15, 2024
c04905c
fix code to support servicebus in azd composability (#29)
saragluna Nov 19, 2024
9f9c553
Handle environment variable placeholder in property file. (#31)
rujche Nov 19, 2024
521d706
Inject AzureEventHubsKafkaAutoConfiguration package path based on spr…
haoozhang Nov 19, 2024
3727ead
Fix some bindings specified by uses keywork not work (#30)
rujche Nov 19, 2024
feb1cf5
support eventhubs when using azd composability (#33)
saragluna Nov 20, 2024
c3e9caf
Add the missed codes for "storage" (#36)
rujche Nov 20, 2024
bf02b93
Add values for all environment variables (#35)
rujche Nov 20, 2024
8ca2115
Improve the prompt message for database (#37)
rujche Nov 20, 2024
27f2cc5
1. Add log about detecting rule. 2. Avoid duplicated queue name for s…
rujche Nov 21, 2024
1dc2e3e
Users can continue to use azd when java analyzer fails (#39)
rujche Nov 21, 2024
4c89041
fix code to support servicebus jms with managed identity in azd compo…
saragluna Nov 21, 2024
06ca3c5
Update azure yaml schema (#32)
haoozhang Nov 22, 2024
c8351bf
Fix code to support kafka when azd compose enabled (#42)
haoozhang Nov 22, 2024
419b699
Refactor code (#41)
rujche Nov 22, 2024
9b5d218
support cosmos when azd compose enabled (#43)
haoozhang Nov 22, 2024
ace3a60
Update yaml language server (#44)
rujche Nov 22, 2024
d8f8499
Merge branch 'main' into feature/sjad
saragluna Nov 22, 2024
7d5bdd6
Add "storageAccountResource" in azure.yaml.json (#45)
rujche Nov 22, 2024
8c72593
fix test
saragluna Nov 22, 2024
a7ef892
Fix bug: Deploy failed for the second time when resource name too lon…
rujche Nov 25, 2024
817ce35
replace placeholders when reading pom.xml (#50)
haoozhang Nov 28, 2024
40c305d
Avoid maintain env list in multiple place (#46)
rujche Nov 28, 2024
f74aa50
Update the wording or azd init in VS Code extension (#51)
saragluna Nov 28, 2024
f4eddd0
Fix pipeline failures. (#52)
rujche Nov 28, 2024
dad722f
Fix pipeline failure. (#53)
rujche Nov 28, 2024
5081210
Fix lint realted problems and enable related GitHub actions (#54)
rujche Nov 28, 2024
85c5ce1
1. fix test. 2. pack build multi-module (#55)
haoozhang Nov 29, 2024
b5aceaa
Deploy PetClinic microservices using azd (#49)
haoozhang Dec 2, 2024
45057e6
Delete SpringCloudAzureDep, use Metadata instead. (#57)
rujche Dec 2, 2024
dcb4da6
Change auth type string to camel case (#59)
rujche Dec 3, 2024
05a38d8
A few enhancements for deploy spring petclinic microservices (#60)
haoozhang Dec 3, 2024
1064e5b
detect spring.application.name (#62)
haoozhang Dec 3, 2024
62d2958
User can get prompt when there is error about passwordless dependency…
rujche Dec 3, 2024
3947823
Fix SJAD sample (#56)
saragluna Dec 3, 2024
d3a84ff
Merge branch 'main' into feature/sjad
saragluna Dec 3, 2024
0d729ce
Change auth type string from Pascalto camel case. (#64)
rujche Dec 4, 2024
529e450
Refactor to include application name, spring cloud azure, eureka, con…
haoozhang Dec 4, 2024
6d96a35
Delete password check when using managed identity as auth type. Becau…
rujche Dec 4, 2024
d12864e
fix: not all service use db, so only prompt those services that use d…
haoozhang Dec 4, 2024
86e8151
dleete DB only if no other service used (#67)
haoozhang Dec 4, 2024
5413462
Fix service connector name conflict (#69)
haoozhang Dec 5, 2024
7881d29
Detect database name from property file (#68)
rujche Dec 6, 2024
4c5e08d
Merge branch 'main' into feature/sjad
saragluna Dec 9, 2024
86aa88f
Fix bug: environment variables not added when not enable compose mode…
rujche Dec 9, 2024
240f369
when MI auth enabled (passwordless-enabled = true), we still need to …
haoozhang Dec 10, 2024
5586d2c
Detect database name from property file (#70)
rujche Dec 10, 2024
2a16a3a
skip some tests (#75)
saragluna Dec 10, 2024
d81ecc7
Merge branch 'main' into feature/sjad
saragluna Dec 10, 2024
d1c179a
In a multi-module project, when the relative path of a sub-module con…
haoozhang Dec 11, 2024
97b96e3
Update todo description. (#76)
rujche Dec 11, 2024
3ac54fa
Enrich rules of detecting PostgreSQL. (#78)
rujche Dec 12, 2024
9f748b1
When placeholder not detected in application.yml, prompt user to inpu…
haoozhang Dec 17, 2024
eb91231
Enhancement: support to resolve placeholder for Kafka and detect even…
haoozhang Dec 17, 2024
f38b63f
Add missed environment variables when use PostgreSql (or MySql) + use…
rujche Dec 17, 2024
d037aef
Use effective pom to analyze pom file if possible (#80)
rujche Dec 17, 2024
ac0bc2f
Improve code of pom analyze (#83)
rujche Dec 18, 2024
0311aa3
Improve the code of maven command (#84)
rujche Dec 18, 2024
400bf73
Fix: connection name too long. (#86)
rujche Dec 18, 2024
0b4143c
Detect spring boot app by "spring-boot-maven-plugin". (#87)
rujche Dec 18, 2024
1c6b531
Make message more clear when lack dependency. (#88)
rujche Dec 18, 2024
5055870
when eureka server / config server removed during detect confirm, the…
haoozhang Dec 23, 2024
0ac1394
inject frontend A's url into B's env (#90)
haoozhang Dec 23, 2024
f23efa5
Fix: when pack build multi-module project, use actual parent path, in…
haoozhang Dec 24, 2024
999ad9d
Fix: SpringFrontend not displayed in detect confirm message. (#95)
rujche Dec 26, 2024
7d0b49b
detect `server.port` property and use it when determining port (#94)
haoozhang Dec 26, 2024
2a155a4
Use effective pom or simulated effective pom instead carry parent pom…
rujche Dec 26, 2024
d02c6e5
Support maven profile in simulated effective pom (#97)
rujche Dec 27, 2024
b9830c7
Fix: Application name malformed causes azd up failing (#96)
rujche Dec 27, 2024
22d2457
Add a default Dockerfile if not exists for java project (#93)
haoozhang Dec 31, 2024
60f57d0
Support detect spring-integration-eventhubs, spring-messaging-eventhu…
haoozhang Dec 31, 2024
a3baacd
Merge maven_command.go and maven.go (#100)
rujche Jan 2, 2025
af63e2e
Use local maven repository as cache when create simulated effective p…
rujche Jan 7, 2025
917c310
Enhancement for detecting java parent project and excluding non-runna…
haoozhang Jan 9, 2025
c8dae89
Fix the azd add not working bug in sjad (#104)
saragluna Jan 13, 2025
86e2923
Merge branch 'main' into feature/sjad
saragluna Jan 13, 2025
1de01c7
Delete SJAD created Dockerfile. (#106)
rujche Jan 15, 2025
b31578f
fix the bug that app cannot fetch Envs (#107)
haoozhang Jan 20, 2025
242f9a0
Add UTs for app_init, detect_confirm, infra_confirm, and scaffold (#102)
saragluna Jan 20, 2025
85e3d3d
Support deploying app without web server (#101)
rujche Jan 21, 2025
1a5ffb5
Split `spec_service_binding.go` by app type: `Spring Boot app`, `othe…
rujche Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add support for service bus
saragluna committed Oct 8, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
commit df2f5f2fcf1a9e3ab20f26f017d9f41f8f9bea83
28 changes: 12 additions & 16 deletions cli/azd/internal/appdetect/appdetect.go
Original file line number Diff line number Diff line change
@@ -132,22 +132,18 @@ func (db DatabaseDep) Display() string {
return ""
}

type AzureDep string
//type AzureDep string

const (
AzureStorage AzureDep = "storage"
AzureServiceBus AzureDep = "servicebus"
)
type AzureDep interface {
ResourceDisplay() string
}

func (azureDep AzureDep) Display() string {
switch azureDep {
case AzureStorage:
return "Azure Storage"
case AzureServiceBus:
return "Azure Service Bus"
}
type AzureDepServiceBus struct {
Queues []string
}

return ""
func (a AzureDepServiceBus) ResourceDisplay() string {
return "Azure Service Bus"
}

type Project struct {
@@ -370,9 +366,9 @@ func enrichFromJavaProject(azureYaml javaanalyze.AzureYaml, project *Project) {
} else if resource.GetType() == "Redis" {
project.DatabaseDeps = append(project.DatabaseDeps, DbRedis)
} else if resource.GetType() == "Azure Service Bus" {
project.AzureDeps = append(project.AzureDeps, AzureServiceBus)
} else if resource.GetType() == "Azure Storage" {
project.AzureDeps = append(project.AzureDeps, AzureStorage)
project.AzureDeps = append(project.AzureDeps, AzureDepServiceBus{
Queues: resource.(*javaanalyze.ServiceBusResource).Queues,
})
}
}
}
5 changes: 2 additions & 3 deletions cli/azd/internal/repository/app_init.go
Original file line number Diff line number Diff line change
@@ -38,9 +38,8 @@ var dbMap = map[appdetect.DatabaseDep]struct{}{
appdetect.DbRedis: {},
}

var azureDepMap = map[appdetect.AzureDep]struct{}{
appdetect.AzureServiceBus: {},
appdetect.AzureStorage: {},
var azureDepMap = map[string]struct{}{
appdetect.AzureDepServiceBus{}.ResourceDisplay(): {},
}

// InitFromApp initializes the infra directory and project file from the current existing app.
31 changes: 16 additions & 15 deletions cli/azd/internal/repository/detect_confirm.go
Original file line number Diff line number Diff line change
@@ -42,12 +42,17 @@ const (
EntryKindModified EntryKind = "modified"
)

type Pair struct {
first appdetect.AzureDep
second EntryKind
}

// detectConfirm handles prompting for confirming the detected services and databases
type detectConfirm struct {
// detected services and databases
Services []appdetect.Project
Databases map[appdetect.DatabaseDep]EntryKind
AzureDeps map[appdetect.AzureDep]EntryKind
AzureDeps map[string]Pair

// the root directory of the project
root string
@@ -60,7 +65,7 @@ type detectConfirm struct {
// Init initializes state from initial detection output
func (d *detectConfirm) Init(projects []appdetect.Project, root string) {
d.Databases = make(map[appdetect.DatabaseDep]EntryKind)
d.AzureDeps = make(map[appdetect.AzureDep]EntryKind)
d.AzureDeps = make(map[string]Pair)
d.Services = make([]appdetect.Project, 0, len(projects))
d.modified = false
d.root = root
@@ -77,8 +82,8 @@ func (d *detectConfirm) Init(projects []appdetect.Project, root string) {
}

for _, azureDep := range project.AzureDeps {
if _, supported := azureDepMap[azureDep]; supported {
d.AzureDeps[azureDep] = EntryKindDetected
if _, supported := azureDepMap[azureDep.ResourceDisplay()]; supported {
d.AzureDeps[azureDep.ResourceDisplay()] = Pair{azureDep, EntryKindDetected}
}
}
}
@@ -104,8 +109,9 @@ func (d *detectConfirm) captureUsage(
}

azureDepNames := make([]string, 0, len(d.AzureDeps))
for azureDep := range d.AzureDeps {
azureDepNames = append(azureDepNames, string(azureDep))

for _, pair := range d.AzureDeps {
azureDepNames = append(azureDepNames, pair.first.ResourceDisplay())
}

tracing.SetUsageAttributes(
@@ -250,21 +256,16 @@ func (d *detectConfirm) render(ctx context.Context) error {
d.console.Message(ctx, "\n"+output.WithBold("Detected Azure dependencies:")+"\n")
}
for azureDep, entry := range d.AzureDeps {
switch azureDep {
case appdetect.AzureStorage:
recommendedServices = append(recommendedServices, "Azure Storage")
case appdetect.AzureServiceBus:
recommendedServices = append(recommendedServices, "Azure Service Bus")
}
recommendedServices = append(recommendedServices, azureDep)

status := ""
if entry == EntryKindModified {
if entry.second == EntryKindModified {
status = " " + output.WithSuccessFormat("[Updated]")
} else if entry == EntryKindManual {
} else if entry.second == EntryKindManual {
status = " " + output.WithSuccessFormat("[Added]")
}

d.console.Message(ctx, " "+color.BlueString(azureDep.Display())+status)
d.console.Message(ctx, " "+color.BlueString(azureDep)+status)
d.console.Message(ctx, "")
}

35 changes: 20 additions & 15 deletions cli/azd/internal/repository/infra_confirm.go
Original file line number Diff line number Diff line change
@@ -103,10 +103,10 @@ func (i *Initializer) infraSpecFromDetect(
}
}

for azureDep := range detect.AzureDeps {
infraSpec, err := i.promptForAzureResource(ctx, azureDep, spec)
for _, azureDep := range detect.AzureDeps {
err := i.promptForAzureResource(ctx, azureDep.first, &spec)
if err != nil {
return infraSpec, err
return scaffold.InfraSpec{}, err
}
}

@@ -157,6 +157,13 @@ func (i *Initializer) infraSpecFromDetect(
}
}
}

for _, azureDep := range svc.AzureDeps {
switch azureDep.(type) {
case appdetect.AzureDepServiceBus:
serviceSpec.AzureServiceBus = spec.AzureServiceBus
}
}
spec.Services = append(spec.Services, serviceSpec)
}

@@ -219,18 +226,18 @@ func (i *Initializer) infraSpecFromDetect(
func (i *Initializer) promptForAzureResource(
ctx context.Context,
azureDep appdetect.AzureDep,
spec scaffold.InfraSpec) (scaffold.InfraSpec, error) {
spec *scaffold.InfraSpec) error {
azureDepPrompt:
for {
azureDepName, err := i.console.Prompt(ctx, input.ConsoleOptions{
Message: fmt.Sprintf("Input the name of the Azure dependency (%s)", azureDep.Display()),
Message: fmt.Sprintf("Input the name of the Azure dependency (%s)", azureDep.ResourceDisplay()),
Help: "Hint: Azure dependency name\n\n" +
"Name of the Azure dependency that the app connects to. " +
"This dependency will be created after running azd provision or azd up." +
"\nYou may be able to skip this step by hitting enter, in which case the dependency will not be created.",
})
if err != nil {
return scaffold.InfraSpec{}, err
return err
}

if strings.ContainsAny(azureDepName, " ") {
@@ -241,7 +248,7 @@ azureDepPrompt:
Message: fmt.Sprintf("Continue with name '%s'?", azureDepName),
})
if err != nil {
return scaffold.InfraSpec{}, err
return err
}

if !confirm {
@@ -256,25 +263,23 @@ azureDepPrompt:
Message: fmt.Sprintf("Continue with name '%s'?", azureDepName),
})
if err != nil {
return scaffold.InfraSpec{}, err
return err
}

if !confirm {
continue azureDepPrompt
}
}

switch azureDep {
case appdetect.AzureServiceBus:

switch azureDep.(type) {
case appdetect.AzureDepServiceBus:
spec.AzureServiceBus = &scaffold.AzureDepServiceBus{
Name: azureDepName,
Name: azureDepName,
Queues: azureDep.(appdetect.AzureDepServiceBus).Queues,
}
break azureDepPrompt
case appdetect.AzureStorage:
break azureDepPrompt
}
break azureDepPrompt
}
return spec, nil
return nil
}
2 changes: 1 addition & 1 deletion cli/azd/internal/repository/infra_prompt.go
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ type serviceBusPrompt struct {
}

func (s *serviceBusPrompt) Type() string {
return appdetect.AzureServiceBus.Display()
return appdetect.AzureDepServiceBus{}.ResourceDisplay()
}

func (s *serviceBusPrompt) Properties() map[string]string {
7 changes: 7 additions & 0 deletions cli/azd/internal/scaffold/scaffold.go
Original file line number Diff line number Diff line change
@@ -136,6 +136,13 @@ func ExecInfra(
}
}

if spec.AzureServiceBus != nil {
err = Execute(t, "azure-service-bus.bicep", spec.AzureServiceBus, filepath.Join(infraApp, "azure-service-bus.bicep"))
if err != nil {
return fmt.Errorf("scaffolding service bus: %w", err)
}
}

for _, svc := range spec.Services {
err = Execute(t, "host-containerapp.bicep", svc, filepath.Join(infraApp, svc.Name+".bicep"))
if err != nil {
40 changes: 40 additions & 0 deletions cli/azd/resources/scaffold/templates/azure-service-bus.bicept
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{define "azure-service-bus.bicep" -}}
param serviceBusNamespaceName string
param location string
param tags object = {}

resource serviceBusNamespace 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' = {
name: serviceBusNamespaceName
location: location
tags: tags
sku: {
name: 'Standard'
tier: 'Standard'
capacity: 1
}
}

{{- range $index, $element := .Queues }}
resource serviceBusQueue_{{ $index }} 'Microsoft.ServiceBus/namespaces/queues@2022-01-01-preview' = {
parent: serviceBusNamespace
name: '{{ $element }}'
properties: {
lockDuration: 'PT5M'
maxSizeInMegabytes: 1024
requiresDuplicateDetection: false
requiresSession: false
defaultMessageTimeToLive: 'P10675199DT2H48M5.4775807S'
deadLetteringOnMessageExpiration: false
duplicateDetectionHistoryTimeWindow: 'PT10M'
maxDeliveryCount: 10
autoDeleteOnIdle: 'P10675199DT2H48M5.4775807S'
enablePartitioning: false
enableExpress: false
}
}
{{end}}

output serviceBusNamespaceId string = serviceBusNamespace.id
output serviceBusNamespaceApiVersion string = serviceBusNamespace.apiVersion
output serviceBusConnectionString string = listKeys('${serviceBusNamespace.id}/AuthorizationRules/RootManageSharedAccessKey', serviceBusNamespace.apiVersion).primaryConnectionString
{{ end}}
10 changes: 10 additions & 0 deletions cli/azd/resources/scaffold/templates/host-containerapp.bicept
Original file line number Diff line number Diff line change
@@ -23,6 +23,10 @@ param postgresDatabasePassword string
param mysqlDatabaseId string
param mysqlIdentityName string
{{- end}}
{{- if .AzureServiceBus}}
@secure()
param azureServiceBusConnectionString string
{{- end}}
{{- if .DbRedis}}
param redisName string
{{- end}}
@@ -152,6 +156,12 @@ resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
value: postgresDatabasePassword
}
{{- end}}
{{- if .AzureServiceBus}}
{
name: 'SPRING_CLOUD_AZURE_SERVICEBUS_CONNECTION_STRING'
value: azureServiceBusConnectionString
}
{{- end}}
],
map(secrets, secret => {
name: secret.secretRef
18 changes: 17 additions & 1 deletion cli/azd/resources/scaffold/templates/main.bicept
Original file line number Diff line number Diff line change
@@ -91,7 +91,7 @@ module appsEnv './shared/apps-env.bicep' = {
}
scope: rg
}
{{- if (or (or .DbCosmosMongo .DbPostgres) .DbMySql)}}
{{- if (or (or (or .DbCosmosMongo .DbPostgres) .DbMySql) .AzureServiceBus)}}

resource vault 'Microsoft.KeyVault/vaults@2022-07-01' existing = {
name: keyVault.outputs.name
@@ -142,6 +142,19 @@ module mysqlDb './app/db-mysql.bicep' = {
scope: rg
}
{{- end}}

{{- if .AzureServiceBus }}
module serviceBus './app/azure-service-bus.bicep' = {
name: 'serviceBus'
params: {
serviceBusNamespaceName: '${abbrs.serviceBusNamespaces}${resourceToken}'
location: location
tags: tags
}
scope: rg
}
{{- end}}

{{- range .Services}}

module {{bicepName .Name}} './app/{{.Name}}.bicep' = {
@@ -173,6 +186,9 @@ module {{bicepName .Name}} './app/{{.Name}}.bicep' = {
mysqlDatabaseId: mysqlDb.outputs.databaseId
mysqlIdentityName: mysqlDb.outputs.identityName
{{- end}}
{{- if .AzureServiceBus }}
azureServiceBusConnectionString: vault.getSecret(serviceBus.outputs.serviceBusConnectionString)
{{- end}}
{{- if (and .Frontend .Frontend.Backends)}}
apiUrls: [
{{- range .Frontend.Backends}}