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

Use azd binding feature to connect to services #5

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

brycechen1849
Copy link

Reference azd PR for binding feature: Azure/azure-dev#3549, This is a code demo to utilize the new azd feature binding :

  • Use bindings in azure.yaml to define Service Connectors
  • Service Connector configures ConnectionStrings of CosmosDb, ApplicationInsight into an extra Azure App Configuration instance.
  • API node.js code consumes the ConnectionStrings from App Configuration.
  • KeyVault and AppConfigurations works as the infra for reading connetion string, so they still have endpoint in environment variables, with a user-assigned managed identity having rbac role assignment to access these secrets/configuraitons

@jongio jongio marked this pull request as draft April 15, 2024 16:10
infra/app/api.bicep Outdated Show resolved Hide resolved
output AZURE_RESOURCE_GROUP string = rg.name

// Source resource API
// output SERVICE_API_NAME string = api.outputs.SERVICE_API_NAME
Copy link
Member

Choose a reason for hiding this comment

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

Why not output it?

Copy link
Author

Choose a reason for hiding this comment

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

ENV with same name exists at line 211, so it's duplicated

Copy link
Member

Choose a reason for hiding this comment

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

I believe that is needed in that format for azd integration with aca, I'd keep all existing env vars, or do a full regression

@@ -15,8 +15,6 @@ param keyValueNames array = []
@description('Specifies the values of the key-value resources.')
param keyValueValues array = []

@description('The principal ID to grant access to the Azure App Configuration store')
param principalId string
Copy link
Member

Choose a reason for hiding this comment

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

Why remove principal Id? Our design allows the user to run the application locally with their principal Id, so I think by removing this the user will no longer be able to run it locally.

Copy link
Author

@brycechen1849 brycechen1849 Apr 16, 2024

Choose a reason for hiding this comment

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

This rbac role assignment is raised up to main.bicep because container app env needs appConfig endpoint while appConfig needs principal Id from identity created with the container app.
The flow is changed to:

  1. App Config is created
  2. Container app is created with App Config's endpoint address filled in env variable
  3. This Rbac role assignment is created.
    This is to avoid dependency on principal Id before the managed identity is created

brycechen1849 and others added 3 commits April 16, 2024 14:42
Typo

Co-authored-by: Jon Gallant <2163001+jongio@users.noreply.github.com>

try {
logger.info("Populating environment from Azure AppConfiguration...");
const credential = new DefaultAzureCredential({
Copy link

Choose a reason for hiding this comment

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

pls use AppConfig nodejs provider instead of the standard client way to get config from AppConfig, https://learn.microsoft.com/en-us/azure/azure-app-configuration/quickstart-javascript-provider?tabs=windowscommandprompt#setting-up-the-nodejs-app

Copy link
Author

Choose a reason for hiding this comment

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

fixed and will move the PR changes to the azd repo with changes to the repo template. This PR will be discard

@brycechen1849 brycechen1849 force-pushed the jianc/azd-binding-sample branch from e10ec46 to 8024e5c Compare April 18, 2024 06:55
@brycechen1849
Copy link
Author

Hi @jongio , this PR will be deprecated and moved to Azure/azure-dev#3740 , the changes are made to template and repo considering there are common bicep components with a restriction to a limited scope so not to affect other existing todo project repos

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.

3 participants