Skip to content

Commit

Permalink
Containerapp 0.3.12 Release (#5392)
Browse files Browse the repository at this point in the history
  • Loading branch information
StrawnSC authored Oct 7, 2022
1 parent 801093d commit 7a98bcb
Show file tree
Hide file tree
Showing 36 changed files with 75,038 additions and 15,622 deletions.
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@

/src/quota/ @kairu-ms @ZengTaoxu

/src/containerapp/ @calvinsID @haroonf @panchagnula @StrawnSC
/src/containerapp/ @haroonf @panchagnula @StrawnSC @lil131

/src/scvmm/ @nascarsayan

Expand Down
10 changes: 10 additions & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,16 @@
Release History
===============

0.3.12
++++++
* Add 'az containerapp env update' to update managed environment properties
* Add custom domains support to 'az containerapp env create' and 'az containerapp env update'
* 'az containerapp logs show': add new parameter "--type" to allow showing system logs
* Show system environment logs with new command 'az containerapp env logs show'
* Add tcp support for ingress transport and scale rules
* `az containerapp up/github-action add`: Retrieve workflow file name from github actions API
* 'az containerapp create/update': validate revision suffixes

0.3.11
++++++
* Add keda scale rule parameters to 'az containerapp create', 'az containerapp update' and 'az containerapp revision copy'
Expand Down
28 changes: 21 additions & 7 deletions src/containerapp/azext_containerapp/_clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,15 @@ def __init__(self):
self.currTicker = 0

def tick(self):
sys.stdout.write('\r')
sys.stdout.write(self.tickers[self.currTicker] + " Running ..")
sys.stdout.flush()
sys.stderr.write('\r')
sys.stderr.write(self.tickers[self.currTicker] + " Running ..")
sys.stderr.flush()
self.currTicker += 1
self.currTicker = self.currTicker % len(self.tickers)

def flush(self):
sys.stdout.flush()
sys.stdout.write('\r')
sys.stdout.write("\033[K")
sys.stderr.flush()
sys.stderr.write("\r\033[K")


def poll(cmd, request_url, poll_if_status): # pylint: disable=inconsistent-return-statements
Expand Down Expand Up @@ -405,7 +404,7 @@ def get_replica(cls, cmd, resource_group_name, container_app_name, revision_name
def get_auth_token(cls, cmd, resource_group_name, name):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/authtoken?api-version={}"
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/containerApps/{}/getAuthToken?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
Expand Down Expand Up @@ -689,6 +688,21 @@ def check_name_availability(cls, cmd, resource_group_name, name, name_availabili
r = send_raw_request(cmd.cli_ctx, "POST", request_url, body=json.dumps(name_availability_request))
return r.json()

@classmethod
def get_auth_token(cls, cmd, resource_group_name, name):
management_hostname = cmd.cli_ctx.cloud.endpoints.resource_manager
sub_id = get_subscription_id(cmd.cli_ctx)
url_fmt = "{}/subscriptions/{}/resourceGroups/{}/providers/Microsoft.App/managedEnvironments/{}/getAuthToken?api-version={}"
request_url = url_fmt.format(
management_hostname.strip('/'),
sub_id,
resource_group_name,
name,
CURRENT_API_VERSION)

r = send_raw_request(cmd.cli_ctx, "POST", request_url)
return r.json()


class GitHubActionClient():
@classmethod
Expand Down
3 changes: 3 additions & 0 deletions src/containerapp/azext_containerapp/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
NAME_INVALID = "Invalid"
NAME_ALREADY_EXISTS = "AlreadyExists"

LOG_TYPE_CONSOLE = "console"
LOG_TYPE_SYSTEM = "system"

ACR_TASK_TEMPLATE = """version: v1.1.0
steps:
- cmd: mcr.microsoft.com/oryx/cli:20220811.1 oryx dockerfile --bind-port {{target_port}} --output ./Dockerfile .
Expand Down
33 changes: 32 additions & 1 deletion src/containerapp/azext_containerapp/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,38 @@
az containerapp up -n MyContainerapp --image myregistry.azurecr.io/myImage:myTag --ingress external --target-port 80 --environment MyEnv
"""

helps['containerapp env logs'] = """
type: group
short-summary: Show container app environment logs
"""

helps['containerapp env logs show'] = """
type: command
short-summary: Show past environment logs and/or print logs in real time (with the --follow parameter)
examples:
- name: Fetch the past 20 lines of logs from an app and return
text: |
az containerapp env logs show -n MyEnvironment -g MyResourceGroup
- name: Fetch 30 lines of past logs logs from an environment and print logs as they come in
text: |
az containerapp env logs show -n MyEnvironment -g MyResourceGroup --follow --tail 30
"""

helps['containerapp logs'] = """
type: group
short-summary: Show container app logs
"""

helps['containerapp logs show'] = """
type: command
short-summary: Show past logs and/or print logs in real time (with the --follow parameter). Note that the logs are only taken from one revision, replica, and container.
short-summary: Show past logs and/or print logs in real time (with the --follow parameter). Note that the logs are only taken from one revision, replica, and container (for non-system logs).
examples:
- name: Fetch the past 20 lines of logs from an app and return
text: |
az containerapp logs show -n MyContainerapp -g MyResourceGroup
- name: Fetch the past 20 lines of system logs from an app and return
text: |
az containerapp logs show -n MyContainerapp -g MyResourceGroup --type system
- name: Fetch 30 lines of past logs logs from an app and print logs as they come in
text: |
az containerapp logs show -n MyContainerapp -g MyResourceGroup --follow --tail 30
Expand Down Expand Up @@ -351,6 +371,17 @@
--location eastus2
"""

helps['containerapp env update'] = """
type: command
short-summary: Update a Container Apps environment.
examples:
- name: Update an environment's custom domain configuration.
text: |
az containerapp env update -n MyContainerappEnvironment -g MyResourceGroup \\
--dns-suffix my-suffix.net --certificate-file MyFilePath \\
--certificate-password MyCertPass
"""


helps['containerapp env delete'] = """
type: command
Expand Down
12 changes: 10 additions & 2 deletions src/containerapp/azext_containerapp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,17 @@
"daprAIInstrumentationKey": None,
"vnetConfiguration": None, # VnetConfiguration
"internalLoadBalancerEnabled": None,
"appLogsConfiguration": None
"appLogsConfiguration": None,
"customDomainConfiguration": None # CustomDomainConfiguration
}
}

CustomDomainConfiguration = {
"dnsSuffix": None,
"certificateValue": None,
"certificatePassword": None
}

AppLogsConfiguration = {
"destination": None,
"logAnalyticsConfiguration": None
Expand Down Expand Up @@ -142,7 +149,8 @@
"fqdn": None,
"external": False,
"targetPort": None,
"transport": None, # 'auto', 'http', 'http2'
"transport": None, # 'auto', 'http', 'http2', 'tcp'
"exposedPort": None,
"traffic": None, # TrafficWeight
"customDomains": None # [CustomDomain]
}
Expand Down
17 changes: 14 additions & 3 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from ._validators import (validate_memory, validate_cpu, validate_managed_env_name_or_id, validate_registry_server,
validate_registry_user, validate_registry_pass, validate_target_port, validate_ingress)
from ._constants import UNAUTHENTICATED_CLIENT_ACTION, FORWARD_PROXY_CONVENTION, MAXIMUM_CONTAINER_APP_NAME_LENGTH, DEFAULT_PORT
from ._constants import UNAUTHENTICATED_CLIENT_ACTION, FORWARD_PROXY_CONVENTION, MAXIMUM_CONTAINER_APP_NAME_LENGTH, LOG_TYPE_CONSOLE, LOG_TYPE_SYSTEM


def load_arguments(self, _):
Expand Down Expand Up @@ -48,6 +48,11 @@ def load_arguments(self, _):
c.argument('revision', help="The name of the container app revision. Defaults to the latest revision.")
c.argument('name', name_type, id_part=None, help="The name of the Containerapp.")
c.argument('resource_group_name', arg_type=resource_group_name_type, id_part=None)
c.argument('kind', options_list=["--type", "-t"], help="Type of logs to stream", arg_type=get_enum_type([LOG_TYPE_CONSOLE, LOG_TYPE_SYSTEM]), default=LOG_TYPE_CONSOLE)

with self.argument_context('containerapp env logs show') as c:
c.argument('follow', help="Print logs in real time if present.", arg_type=get_three_state_flag())
c.argument('tail', help="The number of past logs to print (0-300)", type=int, default=20)

# Replica
with self.argument_context('containerapp replica') as c:
Expand Down Expand Up @@ -79,7 +84,7 @@ def load_arguments(self, _):
c.argument('max_replicas', type=int, help="The maximum number of replicas.")
c.argument('scale_rule_name', options_list=['--scale-rule-name', '--srn'], help="The name of the scale rule.")
c.argument('scale_rule_type', options_list=['--scale-rule-type', '--srt'], help="The type of the scale rule. Default: http.")
c.argument('scale_rule_http_concurrency', type=int, options_list=['--scale-rule-http-concurrency', '--srhc'], help="The maximum number of concurrent http requests before scale out. Only supported for http scale rules.")
c.argument('scale_rule_http_concurrency', type=int, options_list=['--scale-rule-http-concurrency', '--srhc', '--srtc', '--scale-rule-tcp-concurrency'], help="The maximum number of concurrent requests before scale out. Only supported for http and tcp scale rules.")
c.argument('scale_rule_metadata', nargs="+", options_list=['--scale-rule-metadata', '--srm'], help="Scale rule metadata. Metadata must be in format \"<key>=<value> <key>=<value> ...\".")
c.argument('scale_rule_auth', nargs="+", options_list=['--scale-rule-auth', '--sra'], help="Scale rule auth parameters. Auth parameters must be in format \"<triggerParameter>=<secretRef> <triggerParameter>=<secretRef> ...\".")

Expand Down Expand Up @@ -150,6 +155,12 @@ def load_arguments(self, _):
c.argument('platform_reserved_cidr', options_list=['--platform-reserved-cidr'], help='IP range in CIDR notation that can be reserved for environment infrastructure IP addresses. It must not overlap with any other Subnet IP ranges')
c.argument('platform_reserved_dns_ip', options_list=['--platform-reserved-dns-ip'], help='An IP address from the IP range defined by Platform Reserved CIDR that will be reserved for the internal DNS server.')
c.argument('internal_only', arg_type=get_three_state_flag(), options_list=['--internal-only'], help='Boolean indicating the environment only has an internal load balancer. These environments do not have a public static IP resource, therefore must provide infrastructureSubnetResourceId if enabling this property')

with self.argument_context('containerapp env', arg_group='Custom Domain') as c:
c.argument('hostname', options_list=['--custom-domain-dns-suffix', '--dns-suffix'], help='The DNS suffix for the environment\'s custom domain.')
c.argument('certificate_file', options_list=['--custom-domain-certificate-file', '--certificate-file'], help='The filepath of the certificate file (.pfx or .pem) for the environment\'s custom domain. To manage certificates for container apps, use `az containerapp env certificate`.')
c.argument('certificate_password', options_list=['--custom-domain-certificate-password', '--certificate-password'], help='The certificate file password for the environment\'s custom domain.')

with self.argument_context('containerapp env create') as c:
c.argument('zone_redundant', options_list=["--zone-redundant", "-z"], help="Enable zone redundancy on the environment. Cannot be used without --infrastructure-subnet-resource-id. If used with --location, the subnet's location must match")

Expand Down Expand Up @@ -278,7 +289,7 @@ def load_arguments(self, _):
c.argument('name', configured_default='name', id_part=None)
c.argument('managed_env', configured_default='managed_env')
c.argument('registry_server', configured_default='registry_server')
c.argument('source', help=f'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 Oryx. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.')
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 Oryx. See the supported Oryx runtimes here: https://github.com/microsoft/Oryx/blob/main/doc/supportedRuntimeVersions.md.')
c.argument('image', options_list=['--image', '-i'], help="Container image, e.g. publisher/image-name:tag.")
c.argument('browse', help='Open the app in a web browser after creation and deployment, if possible.')

Expand Down
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_up_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def build_container_from_source(self, image_name, source):
run_client = cf_acr_runs(self.cmd.cli_ctx)
task_command_kwargs = {"resource_type": ResourceType.MGMT_CONTAINERREGISTRY, 'operation_group': 'webhooks'}
old_command_kwargs = {}
for key in task_command_kwargs:
for key in task_command_kwargs: # pylint: disable=consider-using-dict-items
old_command_kwargs[key] = self.cmd.command_kwargs.get(key)
self.cmd.command_kwargs[key] = task_command_kwargs[key]

Expand Down Expand Up @@ -809,7 +809,7 @@ def _create_github_action(
try:
action = GitHubActionClient.show(cmd=app.cmd, resource_group_name=app.resource_group.name, name=app.name)
if action:
trigger_workflow(token, repo, app.name, branch)
trigger_workflow(token, repo, action["properties"]["githubActionConfiguration"]["workflowName"], branch)
except: # pylint: disable=bare-except
pass

Expand Down
Loading

0 comments on commit 7a98bcb

Please sign in to comment.