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

[containerapp] Add support to initialize Dapr components #6857

Merged

Conversation

shubham1172
Copy link
Member

@shubham1172 shubham1172 commented Oct 12, 2023

This PR adds support to initialize dapr-components in a containerapps environment for development purpose, and introduces a new command - az containerapp env dapr-component init.

Sample code to try out this feature: https://github.com/shubham1172/aca-dapr-example

Behaviour overview:

  1. If user runs dapr-component init (DCI) on a fresh ContainerApps environment, it creates the dev service and Dapr component with a binding to the dev service.
  2. If user runs DCI when a Dapr component with the same name already exists -
    1. If the component was created by DCI, overwrite the component.
    2. Otherwise throw an error (users should not lose their component with an overwrite).
  3. If the user runs DCI when a dev service already exists, skip its creation.

Screenshots

Help text:
image

Running the command on a fresh containerapps:
image

Running the command, a second time:
image

Running the command when a Dapr component already exists (user created):
image

Statestore component definition, created by init command:
image

This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az containerapp env dapr-component

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)

FYI to run azdev test, had to do the following:

export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
azdev test test_containerapp_env_dapr_components --live

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

@azure-client-tools-bot-prd
Copy link

azure-client-tools-bot-prd bot commented Oct 12, 2023

⚠️Azure CLI Extensions Breaking Change Test
⚠️containerapp
rule cmd_name rule_message suggest_message
⚠️ 1001 - CmdAdd containerapp env dapr-component init cmd containerapp env dapr-component init added

@azure-client-tools-bot-prd
Copy link

Hi @shubham1172,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Collaborator

yonzhan commented Oct 12, 2023

containerapp

@shubham1172 shubham1172 changed the title [WIP][containerapp] Add support to initialize Dapr components [containerapp] Add support to initialize Dapr components Oct 19, 2023
@shubham1172 shubham1172 marked this pull request as ready for review October 19, 2023 13:37
@yonzhan
Copy link
Collaborator

yonzhan commented Oct 19, 2023

Please fix CI issues.

@shubham1172
Copy link
Member Author

Thanks @yonzhan, done!

@shubham1172 shubham1172 changed the title [containerapp] Add support to initialize Dapr components [WIP][containerapp] Add support to initialize Dapr components Oct 23, 2023
Signed-off-by: Shubham Sharma <[email protected]>
Signed-off-by: Shubham Sharma <[email protected]>
;

Signed-off-by: Shubham Sharma <[email protected]>
g

Signed-off-by: Shubham Sharma <[email protected]>
Signed-off-by: Shubham Sharma <[email protected]>
Signed-off-by: Shubham Sharma <[email protected]>
Copy link
Contributor

@Greedygre Greedygre left a comment

Choose a reason for hiding this comment

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

LGTM @Juliehzl Could you help to review this PR?

@wangzelin007
Copy link
Member

/azp run

Copy link

Azure Pipelines successfully started running 2 pipeline(s).

Signed-off-by: Shubham Sharma <[email protected]>
Signed-off-by: Shubham Sharma <[email protected]>
@zhoxing-ms
Copy link
Contributor

@shubham1172 Please resolve the conflict

Signed-off-by: Shubham Sharma <[email protected]>
@wangzelin007 wangzelin007 merged commit 4565b96 into Azure:main Nov 7, 2023
14 checks passed
@@ -389,6 +389,18 @@
az containerapp env certificate delete -g MyResourceGroup --name MyEnvironment --thumbprint MyCertificateThumbprint
"""

helps['containerapp env dapr-component init'] = """
type: command
short-summary: Initializes Dapr components and dev services for an environment.
Copy link
Contributor

Choose a reason for hiding this comment

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

Initializes -> Initialize
to align with other commands

@@ -66,6 +66,10 @@ def load_arguments(self, _):
c.argument('managed_certificates_only', options_list=['--managed-certificates-only', '-m'], help='List managed certificates only.')
c.argument('private_key_certificates_only', options_list=['--private-key-certificates-only', '-p'], help='List private-key certificates only.')

with self.argument_context('containerapp env dapr-component init') as c:
c.argument('statestore', help="The state store component and dev service to create.")
Copy link
Contributor

Choose a reason for hiding this comment

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

could you use argument --state-store which will be easy to view for customer like what we do for most arguments? For arguments with multiple words should be separated with -

Copy link
Member Author

Choose a reason for hiding this comment

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

Hi, for users coming from the Dapr world, they will be more familiar with statestore and pubsub. Also please check #6857 (comment)

@@ -66,6 +66,10 @@ def load_arguments(self, _):
c.argument('managed_certificates_only', options_list=['--managed-certificates-only', '-m'], help='List managed certificates only.')
c.argument('private_key_certificates_only', options_list=['--private-key-certificates-only', '-p'], help='List private-key certificates only.')

with self.argument_context('containerapp env dapr-component init') as c:
c.argument('statestore', help="The state store component and dev service to create.")
c.argument('pubsub', help="The pubsub component and dev service to create.")
Copy link
Contributor

Choose a reason for hiding this comment

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

should --pub-sub be easy to understand for customer?

Copy link
Member Author

Choose a reason for hiding this comment

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

Same as above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Auto-Assign Auto assign by bot ContainerApp
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants