Azure-Samples / acme-fitness-store

Sample - how to deploy Spring Boot apps to Azure?
https://docs.microsoft.com/en-us/azure/spring-cloud/overview
MIT License
84 stars 157 forks source link

Connection String Modified for Order Service #184

Closed yoshioterada closed 10 months ago

yoshioterada commented 1 year ago

If I configured the original Connection String for Npgsql (C#), following error was showed and couldn't start the order service.

Following is the actual Error during the startup the service.

Unhandled exception. System.ArgumentException: To validate server certificates, 
please use VerifyFull or VerifyCA instead of Require. To disable validation, 
explicitly set 'Trust Server Certificate' to true. 
See https://www.npgsql.org/doc/release-notes/6.0.html for more details.

So I modified the Connection String as follows.

az keyvault secret set --vault-name ${KEY_VAULT} \
    --name "ConnectionStrings--OrderContext" \
    --value "Server=${POSTGRES_SERVER_FULL_NAME}; \
             Database=${ORDER_SERVICE_DB};Port=5432; \
             SSL Mode=Require;Trust Server Certificate=true; \
             User ID=${POSTGRES_SERVER_USER}; \
             Password=${POSTGRES_SERVER_PASSWORD}"

And the above command worked fine with following with following result.

{
  "attributes": {
    "created": "2023-09-25T20:39:16+00:00",
    "enabled": true,
    "expires": null,
    "notBefore": null,
    "recoverableDays": 90,
    "recoveryLevel": "Recoverable+Purgeable",
    "updated": "2023-09-25T20:39:16+00:00"
  },
  "contentType": null,
  "id": "https://acme-fitness-********.vault.azure.net/secrets/ConnectionStrings--OrderContext/***************",
  "kid": null,
  "managed": null,
  "name": "ConnectionStrings--OrderContext",
  "tags": {
    "file-encoding": "utf-8"
  },
  "value": "Server=acme-fitness-db-******.postgres.database.azure.com;              Database=acmefit_order;Port=5432;              SSL Mode=Require;Trust Server Certificate=true;              User ID=acme;              Password=*********"
}