Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
887ecf6
Add --source and --repo to containerapp create
snehapar9 Jun 30, 2023
011439a
Refactored code for containerapp create
snehapar9 Jul 6, 2023
e9fd59b
Merge branch 'main' into snehapar/Add-source-and-repo-to-create
snehapar9 Jul 6, 2023
89241ca
Merge branch 'snehapar/add-source-and-repo-to-containerapp-create' in…
snehapar9 Jul 6, 2023
916259c
Removed extra source param
snehapar9 Jul 6, 2023
1439120
Addressed PR comments
snehapar9 Jul 6, 2023
fb7f4fe
Removed new line
snehapar9 Jul 6, 2023
d18d6c7
Fixed linting errors
snehapar9 Jul 6, 2023
78181aa
Remove new line
snehapar9 Jul 6, 2023
d646bd1
Minor fixes for GitHub repo params
snehapar9 Jul 6, 2023
56e68d4
Addressed PR comments
snehapar9 Jul 8, 2023
1b70cf5
Merge branch 'main' into snehapar/Add-source-and-repo-to-create
snehapar9 Jul 25, 2023
3a809ca
Add source back
snehapar9 Jul 25, 2023
07e1be5
Remove return statement
snehapar9 Jul 25, 2023
25862fb
Addressed PR comments
snehapar9 Jul 26, 2023
5845255
Add source flag to update
snehapar9 Jul 26, 2023
0b2098b
Refactor validation
snehapar9 Jul 26, 2023
3fd9fde
Revert validation change
snehapar9 Jul 26, 2023
557f05e
Add live_only to tests
snehapar9 Jul 26, 2023
6c3a58e
Refactored update
snehapar9 Jul 27, 2023
d1631be
Merge branch 'snehapar/Add-source-and-repo-to-create' into snehapar/A…
snehapar9 Jul 27, 2023
ab167d0
Add tests for update
snehapar9 Jul 27, 2023
2af684f
Update integration test
snehapar9 Jul 28, 2023
a1afa52
Fix help text
snehapar9 Jul 28, 2023
8db50ef
Fix linting
snehapar9 Jul 28, 2023
7afbb53
Fix linting
snehapar9 Jul 28, 2023
2b21611
Addressed PR comments
snehapar9 Jul 31, 2023
5b3b66d
Fix lint errors
snehapar9 Jul 31, 2023
d78c952
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 17, 2023
6341e8a
Fix ci failure
snehapar9 Aug 17, 2023
608438e
Add new line
snehapar9 Aug 19, 2023
e852926
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 28, 2023
07c199b
Address PR comments
snehapar9 Aug 28, 2023
6dc0b8c
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 28, 2023
620e0c0
Performed refactoring
snehapar9 Aug 28, 2023
79dd20d
Refactor and re-run tests
snehapar9 Aug 28, 2023
358b9bb
Fix linting
snehapar9 Aug 29, 2023
82547a3
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 29, 2023
20a266e
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 29, 2023
bdba046
Remove service connectors check
snehapar9 Aug 29, 2023
14d648e
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 29, 2023
69e7d44
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 29, 2023
ee0d465
Address PR comments and re-run tests
snehapar9 Aug 30, 2023
8df8f34
Addressed PR comments
snehapar9 Aug 30, 2023
30b571c
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Aug 30, 2023
b0f79a5
Delete recording
snehapar9 Aug 30, 2023
97eeb45
Add recording for source and repo test
snehapar9 Aug 31, 2023
fb5181d
Fix build failure
snehapar9 Aug 31, 2023
49e1c6c
Address PR comments
snehapar9 Sep 5, 2023
1b1ac8f
Re-run test
snehapar9 Sep 5, 2023
36a8059
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Sep 5, 2023
236bbe1
Update src/containerapp/azext_containerapp/_help.py
snehapar9 Sep 5, 2023
8688b0d
Addressed PR comments
snehapar9 Sep 5, 2023
83e7404
Update comments
snehapar9 Sep 5, 2023
9e8d76e
Addressed PR comments
snehapar9 Sep 6, 2023
dd6abb3
Address PR comments
snehapar9 Sep 6, 2023
3ea22fe
Re-run test
snehapar9 Sep 6, 2023
f23eda9
Addressed PR comments
snehapar9 Sep 7, 2023
091beb0
Addressed PR comments
snehapar9 Sep 7, 2023
9918a9a
Fix linting
snehapar9 Sep 7, 2023
64912b0
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Sep 7, 2023
47ea3d7
Delete recording
snehapar9 Sep 7, 2023
5139b33
Addressed PR comments
snehapar9 Sep 8, 2023
f1ac303
Addressed PR comments
snehapar9 Sep 8, 2023
648090d
Addressed PR comments and performed refactoring
snehapar9 Sep 10, 2023
3aaea4f
Fix linting
snehapar9 Sep 10, 2023
1200a8c
Add env deletion at the end of test
snehapar9 Sep 11, 2023
a2888b1
Re-run test
snehapar9 Sep 11, 2023
85c4302
Address PR comments and re-run tests
snehapar9 Sep 11, 2023
47f563c
Refactor and re-run tests
snehapar9 Sep 12, 2023
ab09b8c
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Sep 12, 2023
b77faac
Merge branch 'main' into snehapar/Add-source-to-containerapp-update
snehapar9 Sep 12, 2023
04a738c
Added comment for live only tests
snehapar9 Sep 13, 2023
0badf02
Add ACR registry validation
snehapar9 Sep 13, 2023
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
2 changes: 2 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Release History
upcoming
++++++
* Add command group 'az containerapp connected-env', support show/list/delete/create connected environment
* 'az containerapp create': support --source and --repo properties
* 'az containerapp update': support --source property

0.3.39
++++++
Expand Down
43 changes: 43 additions & 0 deletions src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -1793,6 +1793,49 @@
az containerapp create -n MyContainerapp -g MyResourceGroup \\
--image my-app:v1.0 --environment MyContainerappConnectedEnv \\
--environment-type connected
- name: Create a container app from a new GitHub Actions workflow in the provided GitHub repository
text: |
az containerapp create -n MyContainerapp -g MyResourceGroup \\
--environment MyContainerappEnv --registry-server MyRegistryServer \\
--registry-user MyRegistryUser --registry-pass MyRegistryPass \\
--repo https://github.com/myAccount/myRepo
- name: Create a Container App from the provided application source
text: |
az containerapp create -n MyContainerapp -g MyResourceGroup \\
--environment MyContainerappEnv --registry-server MyRegistryServer \\
--registry-user MyRegistryUser --registry-pass MyRegistryPass \\
--source .
"""

# containerapp update for preview
helps['containerapp update'] = """
type: command
short-summary: Update a container app. In multiple revisions mode, create a new revision based on the latest revision.
examples:
- name: Update a container app's container image.
text: |
az containerapp update -n MyContainerapp -g MyResourceGroup \\
--image myregistry.azurecr.io/my-app:v2.0
- name: Update a container app's resource requirements and scale limits.
text: |
az containerapp update -n MyContainerapp -g MyResourceGroup \\
--cpu 0.5 --memory 1.0Gi \\
--min-replicas 4 --max-replicas 8
- name: Update a container app with an http scale rule
text: |
az containerapp update -n myapp -g mygroup \\
--scale-rule-name my-http-rule \\
--scale-rule-http-concurrency 50
- name: Update a container app with a custom scale rule
text: |
az containerapp update -n myapp -g mygroup \\
--scale-rule-name my-custom-rule \\
--scale-rule-type my-custom-type \\
--scale-rule-metadata key=value key2=value2 \\
--scale-rule-auth triggerparam=secretref triggerparam=secretref
- name: Update a Container App from the provided application source
text: |
az containerapp update -n MyContainerapp -g MyResourceGroup --source .
"""

# containerapp list for preview
Expand Down
14 changes: 14 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def load_arguments(self, _):
c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help="Name of the workload profile to run the app on.")
c.argument('secret_volume_mount', help="Path to mount all secrets e.g. mnt/secrets")
c.argument('termination_grace_period', type=int, options_list=['--termination-grace-period', '--tgp'], help="Duration in seconds a replica is given to gracefully shut down before it is forcefully terminated. (Default: 30)")
c.argument('source', help="Local directory path containing the application source and Dockerfile for building the container image. Preview: If no Dockerfile is present, a container image is generated using buildpacks. If Docker is not running or buildpacks cannot be used, Oryx will be used to generate the image. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.", is_preview=True)

with self.argument_context('containerapp create', arg_group='Identity') as c:
c.argument('user_assigned', nargs='+', help="Space-separated user identities to be assigned.")
Expand All @@ -137,9 +138,22 @@ def load_arguments(self, _):
c.argument('service_type', help="The service information for dev services.")
c.ignore('service_type')

with self.argument_context('containerapp create', arg_group='GitHub Repository', is_preview=True) as c:
c.argument('repo', help='Create an app via GitHub Actions in the format: https://github.com/<owner>/<repository-name> or <owner>/<repository-name>')
Copy link
Contributor

Choose a reason for hiding this comment

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

Update to The repo used to create app via Github Actions. Typically in the format of https://github.com/<owner>/<repository-name> or <owner>/<repository-name> ?

Copy link
Contributor Author

@snehapar9 snehapar9 Aug 30, 2023

Choose a reason for hiding this comment

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

@Juliehzl re-used this from repo's help text in the up command here

c.argument('token', help='A Personal Access Token with write access to the specified repository. For more information: https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line. If not provided or not found in the cache (and using --repo), a browser page will be opened to authenticate with Github.')
c.argument('branch', options_list=['--branch', '-b'], help='Branch in the provided GitHub repository. Assumed to be the GitHub repository\'s default branch if not specified.')
c.argument('context_path', help='Path in the repository to run docker build. Defaults to "./". Dockerfile is assumed to be named "Dockerfile" and in this directory.')
c.argument('service_principal_client_id', help='The service principal client ID. Used by GitHub Actions to authenticate with Azure.', options_list=["--service-principal-client-id", "--sp-cid"])
c.argument('service_principal_client_secret', help='The service principal client secret. Used by GitHub Actions to authenticate with Azure.', options_list=["--service-principal-client-secret", "--sp-sec"])
c.argument('service_principal_tenant_id', help='The service principal tenant ID. Used by GitHub Actions to authenticate with Azure.', options_list=["--service-principal-tenant-id", "--sp-tid"])

with self.argument_context('containerapp show') as c:
c.argument('show_secrets', help="Show Containerapp secrets.", action='store_true')

# Source
with self.argument_context('containerapp update') as c:
c.argument('source', help="Local directory path containing the application source and Dockerfile for building the container image. Preview: If no Dockerfile is present, a container image is generated using buildpacks. If Docker is not running or buildpacks cannot be used, Oryx will be used to generate the image. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.", is_preview=True)

with self.argument_context('containerapp update', arg_group='Container') as c:
c.argument('image', options_list=['--image', '-i'], help="Container image, e.g. publisher/image-name:tag.")
c.argument('workload_profile_name', options_list=['--workload-profile-name', '-w'], help='The friendly name for the workload profile')
Expand Down
1 change: 0 additions & 1 deletion src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@
LOG_ANALYTICS_RP,
CONTAINER_APPS_RP,
ACR_IMAGE_SUFFIX,
MAXIMUM_CONTAINER_APP_NAME_LENGTH,
ACR_TASK_TEMPLATE,
DEFAULT_PORT)

Expand Down
24 changes: 21 additions & 3 deletions src/containerapp/azext_containerapp/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import re
from azure.cli.core.azclierror import (ValidationError, ResourceNotFoundError, InvalidArgumentValueError,
MutuallyExclusiveArgumentError)
MutuallyExclusiveArgumentError, RequiredArgumentMissingError)
from msrestazure.tools import is_valid_resource_id
from knack.log import get_logger

Expand All @@ -15,13 +15,31 @@
from ._utils import safe_get, is_registry_msi_system
from ._constants import ACR_IMAGE_SUFFIX, LOG_TYPE_SYSTEM, CONNECTED_ENVIRONMENT_RESOURCE_TYPE, \
CONNECTED_ENVIRONMENT_TYPE, MANAGED_ENVIRONMENT_RESOURCE_TYPE, MANAGED_ENVIRONMENT_TYPE, CONTAINER_APPS_RP, \
EXTENDED_LOCATION_RP, CUSTOM_LOCATION_RESOURCE_TYPE
EXTENDED_LOCATION_RP, CUSTOM_LOCATION_RESOURCE_TYPE, MAXIMUM_SECRET_LENGTH
from urllib.parse import urlparse

logger = get_logger(__name__)


# called directly from custom method bc otherwise it disrupts the --environment auto RID functionality
def validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait):
def validate_create(registry_identity, registry_pass, registry_user, registry_server, no_wait, source=None, repo=None, yaml=None, environment_type=None):
if source and repo:
raise MutuallyExclusiveArgumentError("Usage error: --source and --repo cannot be used together. Can either deploy from a local directory or a GitHub repository")
if (source or repo) and yaml:
raise MutuallyExclusiveArgumentError("Usage error: --source or --repo cannot be used with --yaml together. Can either deploy from a local directory or provide a yaml file")
if (source or repo) and environment_type == CONNECTED_ENVIRONMENT_TYPE:
raise MutuallyExclusiveArgumentError("Usage error: --source or --repo cannot be used with --environment-type connectedEnvironment together. Please use --environment-type managedEnvironment")
if source or repo:
if not registry_server:
raise RequiredArgumentMissingError('Usage error: --registry-server is required while using --source or --repo')
if ACR_IMAGE_SUFFIX not in registry_server:
raise InvalidArgumentValueError("Usage error: --registry-server: expected an ACR registry (*.azurecr.io) for --source or --repo")
if repo and registry_server and "azurecr.io" in registry_server:
parsed = urlparse(registry_server)
registry_name = (parsed.netloc if parsed.scheme else parsed.path).split(".")[0]
if registry_name and len(registry_name) > MAXIMUM_SECRET_LENGTH:
raise ValidationError(f"--registry-server ACR name must be less than {MAXIMUM_SECRET_LENGTH} "
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise ValidationError(f"--registry-server ACR name must be less than {MAXIMUM_SECRET_LENGTH} "
raise InvalidArgumentValueError(f"--registry-server ACR name must be less than {MAXIMUM_SECRET_LENGTH} "

Copy link
Contributor

Choose a reason for hiding this comment

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

Actually, ValidationError is acceptable, but personally, I think InvalidArgumentValueError is a more accurate usage.
If you want to maintain consistency with _validate_up_args, then I think it's also OK. Or modify them all to InvalidArgumentValueError

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for taking a look! Just going to keep it as-is so we are consistent with this validation in the up command.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK

"characters when using --repo")
if registry_identity and (registry_pass or registry_user):
raise MutuallyExclusiveArgumentError("Cannot provide both registry identity and username/password")
if is_registry_msi_system(registry_identity) and no_wait:
Expand Down
Loading