Skip to content

Commit

Permalink
Added new dapr component params. (Azure#150)
Browse files Browse the repository at this point in the history
* Added new dapr compononet params.

* Fix style issues and add history entry.

Co-authored-by: Haroon Feisal <haroonfeisal@microsoft.com>
  • Loading branch information
runefa and Haroon Feisal committed Sep 6, 2022
1 parent c93ea9e commit 512fa62
Show file tree
Hide file tree
Showing 6 changed files with 554 additions and 1,118 deletions.
1 change: 1 addition & 0 deletions src/containerapp/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release History

0.3.11
++++++
* Add new dapr params to 'az containerapp dapr enable' and 'az containerapp create'
* 'az containerapp up': autogenerate a docker container with --source when no dockerfile present

0.3.10
Expand Down
6 changes: 5 additions & 1 deletion src/containerapp/azext_containerapp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
"enabled": False,
"appId": None,
"appProtocol": None,
"appPort": None
"appPort": None,
"httpReadBufferSize": None,
"httpMaxRequestSize": None,
"logLevel": None,
"enableApiLogging": None
}

EnvironmentVar = {
Expand Down
4 changes: 4 additions & 0 deletions src/containerapp/azext_containerapp/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def load_arguments(self, _):
c.argument('dapr_app_port', type=int, help="The port Dapr uses to talk to the application.")
c.argument('dapr_app_id', help="The Dapr application identifier.")
c.argument('dapr_app_protocol', arg_type=get_enum_type(['http', 'grpc']), help="The protocol Dapr uses to talk to the application.")
c.argument('dapr_http_read_buffer_size', options_list=['--dapr-http-read-buffer-size', '-dhrbs'], type=int, help="Dapr max size of http header read buffer in KB to handle when sending multi-KB headers..")
c.argument('dapr_http_max_request_size', options_list=['--dapr-http-max-request-size', '-dhmrs'], type=int, help="Increasing max size of request body http and grpc servers parameter in MB to handle uploading of big files.")
c.argument('dapr_log_level', arg_type=get_enum_type(["info", "debug", "warn", "error"]), help="Sets the log level for the Dapr sidecar.")
c.argument('dapr_enable_api_logging', options_list=['--dapr-enable-api-logging', '-dal'], help="Enables API logging for the Dapr sidecar.")

# Configuration
with self.argument_context('containerapp', arg_group='Configuration') as c:
Expand Down
30 changes: 29 additions & 1 deletion src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,10 @@ def create_containerapp(cmd,
dapr_app_port=None,
dapr_app_id=None,
dapr_app_protocol=None,
dapr_http_read_buffer_size=None,
dapr_http_max_request_size=None,
dapr_log_level=None,
dapr_enable_api_logging=False,
revision_suffix=None,
startup_command=None,
args=None,
Expand Down Expand Up @@ -412,6 +416,10 @@ def create_containerapp(cmd,
dapr_def["appId"] = dapr_app_id
dapr_def["appPort"] = dapr_app_port
dapr_def["appProtocol"] = dapr_app_protocol
dapr_def["httpReadBufferSize"] = dapr_http_read_buffer_size
dapr_def["httpMaxRequestSize"] = dapr_http_max_request_size
dapr_def["logLevel"] = dapr_log_level
dapr_def["enableApiLogging"] = dapr_enable_api_logging

config_def = ConfigurationModel
config_def["secrets"] = secrets_def
Expand Down Expand Up @@ -2084,7 +2092,15 @@ def set_secrets(cmd, name, resource_group_name, secrets,
handle_raw_exception(e)


def enable_dapr(cmd, name, resource_group_name, dapr_app_id=None, dapr_app_port=None, dapr_app_protocol=None, no_wait=False):
def enable_dapr(cmd, name, resource_group_name,
dapr_app_id=None,
dapr_app_port=None,
dapr_app_protocol=None,
dapr_http_read_buffer_size=None,
dapr_http_max_request_size=None,
dapr_log_level=None,
dapr_enable_api_logging=False,
no_wait=False):
_validate_subscription_registered(cmd, CONTAINER_APPS_RP)

containerapp_def = None
Expand Down Expand Up @@ -2113,6 +2129,18 @@ def enable_dapr(cmd, name, resource_group_name, dapr_app_id=None, dapr_app_port=
if dapr_app_protocol:
containerapp_def['properties']['configuration']['dapr']['appProtocol'] = dapr_app_protocol

if dapr_http_read_buffer_size:
containerapp_def['properties']['configuration']['dapr']['httpReadBufferSize'] = dapr_http_read_buffer_size

if dapr_http_max_request_size:
containerapp_def['properties']['configuration']['dapr']['httpMaxRequestSize'] = dapr_http_max_request_size

if dapr_log_level:
containerapp_def['properties']['configuration']['dapr']['logLevel'] = dapr_log_level

if dapr_enable_api_logging:
containerapp_def['properties']['configuration']['dapr']['enableApiLogging'] = dapr_enable_api_logging

containerapp_def['properties']['configuration']['dapr']['enabled'] = True

try:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -351,34 +351,59 @@ def test_containerapp_dapr_e2e(self, resource_group):

create_containerapp_env(self, env_name, resource_group)

self.cmd('containerapp create -g {} -n {} --environment {}'.format(resource_group, ca_name, env_name))
self.cmd('containerapp create -g {} -n {} --environment {} --dapr-app-id containerapp --dapr-app-port 800 --dapr-app-protocol grpc -dhmrs 4 -dhrbs 50 --dapr-log-level debug --enable-dapr'.format(resource_group, ca_name, env_name), checks=[
JMESPathCheck('properties.configuration.dapr.appId', "containerapp"),
JMESPathCheck('properties.configuration.dapr.appPort', 800),
JMESPathCheck('properties.configuration.dapr.appProtocol', "grpc"),
JMESPathCheck('properties.configuration.dapr.enabled', True),
JMESPathCheck('properties.configuration.dapr.httpReadBufferSize', 50),
JMESPathCheck('properties.configuration.dapr.httpMaxRequestSize', 4),
JMESPathCheck('properties.configuration.dapr.logLevel', "debug"),
JMESPathCheck('properties.configuration.dapr.enableApiLogging', False),
])

self.cmd('containerapp dapr enable -g {} -n {} --dapr-app-id containerapp1 --dapr-app-port 80 --dapr-app-protocol http'.format(resource_group, ca_name, env_name), checks=[
self.cmd('containerapp dapr enable -g {} -n {} --dapr-app-id containerapp1 --dapr-app-port 80 --dapr-app-protocol http -dal -dhmrs 6 -dhrbs 60 --dapr-log-level warn'.format(resource_group, ca_name, env_name), checks=[
JMESPathCheck('appId', "containerapp1"),
JMESPathCheck('appPort', 80),
JMESPathCheck('appProtocol', "http"),
JMESPathCheck('enabled', True),
JMESPathCheck('httpReadBufferSize', 60),
JMESPathCheck('httpMaxRequestSize', 6),
JMESPathCheck('logLevel', "warn"),
JMESPathCheck('enableApiLogging', True),
])

self.cmd('containerapp show -g {} -n {}'.format(resource_group, ca_name), checks=[
JMESPathCheck('properties.configuration.dapr.appId', "containerapp1"),
JMESPathCheck('properties.configuration.dapr.appPort', 80),
JMESPathCheck('properties.configuration.dapr.appProtocol', "http"),
JMESPathCheck('properties.configuration.dapr.enabled', True),
JMESPathCheck('properties.configuration.dapr.httpReadBufferSize', 60),
JMESPathCheck('properties.configuration.dapr.httpMaxRequestSize', 6),
JMESPathCheck('properties.configuration.dapr.logLevel', "warn"),
JMESPathCheck('properties.configuration.dapr.enableApiLogging', True),
])

self.cmd('containerapp dapr disable -g {} -n {}'.format(resource_group, ca_name, env_name), checks=[
JMESPathCheck('appId', "containerapp1"),
JMESPathCheck('appPort', 80),
JMESPathCheck('appProtocol', "http"),
JMESPathCheck('enabled', False),
JMESPathCheck('httpReadBufferSize', 60),
JMESPathCheck('httpMaxRequestSize', 6),
JMESPathCheck('logLevel', "warn"),
JMESPathCheck('enableApiLogging', True),
])

self.cmd('containerapp show -g {} -n {}'.format(resource_group, ca_name), checks=[
JMESPathCheck('properties.configuration.dapr.appId', "containerapp1"),
JMESPathCheck('properties.configuration.dapr.appPort', 80),
JMESPathCheck('properties.configuration.dapr.appProtocol', "http"),
JMESPathCheck('properties.configuration.dapr.enabled', False),
JMESPathCheck('properties.configuration.dapr.httpReadBufferSize', 60),
JMESPathCheck('properties.configuration.dapr.httpMaxRequestSize', 6),
JMESPathCheck('properties.configuration.dapr.logLevel', "warn"),
JMESPathCheck('properties.configuration.dapr.enableApiLogging', True),
])


Expand Down

0 comments on commit 512fa62

Please sign in to comment.