Skip to content

Use to AVM to support PostgreSql#9

Merged
rujche merged 2 commits into
azure-javaee:feature/sjadfrom
rujche:switch-to-avm-for-postgresql
Nov 4, 2024
Merged

Use to AVM to support PostgreSql#9
rujche merged 2 commits into
azure-javaee:feature/sjadfrom
rujche:switch-to-avm-for-postgresql

Conversation

@rujche

@rujche rujche commented Nov 4, 2024

Copy link
Copy Markdown

Switch to AVM for PostgreSql.

  • Auth by managed identity.
  • Auth by username / password.

Link to sample project: https://github.com/rujche/spring-petclinic/tree/rujche/use-postgresql-support-both-password-and-passwordless

{
principalId: connectionCreatorIdentity.outputs.principalId
principalType: 'ServicePrincipal'
roleDefinitionIdOrName: 'b24988ac-6180-42a0-ab88-20f7382dd24c'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The b24988ac-6180-42a0-ab88-20f7382dd24c is not easy to read. It can be change to display name.

Refs:
https://github.com/Azure/bicep-registry-modules/tree/main/avm/res/app/container-app

image

To keep it align with other places in current file, let's keep it in GUID format. We can change all GUID into display name in another PR.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hold on this change, since I am not sure whether the name can be changed.

{
principalId: connectionCreatorIdentity.outputs.principalId
principalType: 'ServicePrincipal'
roleDefinitionIdOrName: 'b24988ac-6180-42a0-ab88-20f7382dd24c'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This role is added in 4 scopes:

  1. Azure Container Apps Environment.
  2. Azure Container Apps
  3. Azure Container Apps managed identity
  4. Azure Database for PostgreSQL.

Delete any one of above 4 scopes will cause az containerapp connection fail.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need ACA Environment here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without ACA environment, it will return error like Can not read xxx in environment xxx.

if spec.DbMySql != nil {
spec.Parameters = append(spec.Parameters,
Parameter{
Name: "mysqlDatabasePassword",

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use different parameter name will make the bicep file easier to understand.

connectionCreatorIdentity.outputs.resourceId
]
}
runOnce: false

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a great parameter.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are still use deployment script to do the trick, does any database avm support passwordless yet?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this mean?

This parameter can solve this problem: https://github.com/azure-javaee/azure-dev/wiki/Knowledge-Sharing#solution

image

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we are still use deployment script to do the trick, does any database avm support passwordless yet?

We are still use deployment script to do the trick

{
name: 'POSTGRES_URL'
secretRef: 'db-url'
secretRef: 'postgresql-db-url'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The POSTGRES_URL containers password. Keep the original implementation in this PR.

name: 'POSTGRES_PASSWORD'
secretRef: 'db-pass'
name: 'SPRING_DATASOURCE_URL'
value: 'jdbc:postgresql://${postgreServer.outputs.fqdn}:5432/${postgreSqlDatabaseName}'

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SPRING_DATASOURCE_URL doesn't contain password.

@rujche
rujche marked this pull request as ready for review November 4, 2024 02:20
@rujche rujche self-assigned this Nov 4, 2024
@rujche
rujche merged commit 2a21115 into azure-javaee:feature/sjad Nov 4, 2024
@rujche
rujche deleted the switch-to-avm-for-postgresql branch November 4, 2024 05:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants