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

Updated dapr enable/disable to current spec. #40

Merged
merged 2 commits into from
Mar 23, 2022
Merged
Changes from all commits
Commits
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
27 changes: 18 additions & 9 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,24 +1835,27 @@ def enable_dapr(cmd, name, resource_group_name, dapr_app_id=None, dapr_app_port=

_get_existing_secrets(cmd, resource_group_name, name, containerapp_def)

if 'dapr' not in containerapp_def['properties']:
containerapp_def['properties']['dapr'] = {}
if 'configuration' not in containerapp_def['properties']:
containerapp_def['properties']['configuration'] = {}

if 'dapr' not in containerapp_def['properties']['configuration']:
containerapp_def['properties']['configuration']['dapr'] = {}

if dapr_app_id:
containerapp_def['properties']['dapr']['dapr_app_id'] = dapr_app_id
containerapp_def['properties']['configuration']['dapr']['dapr_app_id'] = dapr_app_id

if dapr_app_port:
containerapp_def['properties']['dapr']['dapr_app_port'] = dapr_app_port
containerapp_def['properties']['configuration']['dapr']['dapr_app_port'] = dapr_app_port

if dapr_app_protocol:
containerapp_def['properties']['dapr']['dapr_app_protocol'] = dapr_app_protocol
containerapp_def['properties']['configuration']['dapr']['dapr_app_protocol'] = dapr_app_protocol

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

try:
r = ContainerAppClient.create_or_update(
cmd=cmd, resource_group_name=resource_group_name, name=name, container_app_envelope=containerapp_def, no_wait=no_wait)
return r["properties"]['dapr']
return r["properties"]['configuration']['dapr']
except Exception as e:
handle_raw_exception(e)

Expand All @@ -1871,12 +1874,18 @@ def disable_dapr(cmd, name, resource_group_name, no_wait=False):

_get_existing_secrets(cmd, resource_group_name, name, containerapp_def)

containerapp_def['properties']['dapr']['enabled'] = False
if 'configuration' not in containerapp_def['properties']:
containerapp_def['properties']['configuration'] = {}

if 'dapr' not in containerapp_def['properties']['configuration']:
containerapp_def['properties']['configuration']['dapr'] = {}

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

try:
r = ContainerAppClient.create_or_update(
cmd=cmd, resource_group_name=resource_group_name, name=name, container_app_envelope=containerapp_def, no_wait=no_wait)
return r["properties"]['dapr']
return r["properties"]['configuration']['dapr']
except Exception as e:
handle_raw_exception(e)

Expand Down