Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 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
2 changes: 1 addition & 1 deletion src/containerapp/azext_containerapp/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
"location": None,
"identity": None, # ManagedServiceIdentity
"properties": {
"managedEnvironmentId": None,
"environmentId": None,
"configuration": None, # Configuration
"template": None # Template
},
Expand Down
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_sdk_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ class ContainerApp(TrackedResource):
'location': {'key': 'location', 'type': 'str'},
'identity': {'key': 'identity', 'type': 'ManagedServiceIdentity'},
'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'},
'managed_environment_id': {'key': 'properties.managedEnvironmentId', 'type': 'str'},
'environment_id': {'key': 'properties.environmentId', 'type': 'str'},
'latest_revision_name': {'key': 'properties.latestRevisionName', 'type': 'str'},
'latest_revision_fqdn': {'key': 'properties.latestRevisionFqdn', 'type': 'str'},
'custom_domain_verification_id': {'key': 'properties.customDomainVerificationId', 'type': 'str'},
Expand All @@ -1006,7 +1006,7 @@ def __init__(self, **kwargs):
super(ContainerApp, self).__init__(**kwargs)
self.identity = kwargs.get('identity', None)
self.provisioning_state = None
self.managed_environment_id = kwargs.get('managed_environment_id', None)
self.environment_id = kwargs.get('environment_id', None)
self.latest_revision_name = None
self.latest_revision_fqdn = None
self.custom_domain_verification_id = None
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 @@ -604,14 +604,14 @@ def _get_app_env_and_group(
if not resource_group.name and not resource_group.exists:
matched_apps = [c for c in list_containerapp(cmd) if c["name"].lower() == name.lower()]
if env.name:
matched_apps = [c for c in matched_apps if parse_resource_id(c["properties"]["managedEnvironmentId"])["name"].lower() == env.name.lower()]
matched_apps = [c for c in matched_apps if parse_resource_id(c["properties"]["environmentId"])["name"].lower() == env.name.lower()]
if location:
matched_apps = [c for c in matched_apps if c["location"].lower() == location.lower()]
if len(matched_apps) == 1:
resource_group.name = parse_resource_id(matched_apps[0]["id"])[
"resource_group"
]
env.set_name(matched_apps[0]["properties"]["managedEnvironmentId"])
env.set_name(matched_apps[0]["properties"]["environmentId"])
elif len(matched_apps) > 1:
raise ValidationError(
f"There are multiple containerapps with name {name} on the subscription. "
Expand Down
4 changes: 2 additions & 2 deletions src/containerapp/azext_containerapp/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ def get_custom_domains(cmd, resource_group_name, name, location=None, environmen
_ensure_location_allowed(cmd, location, "Microsoft.App", "containerApps")
if _normalize_location(cmd, app["location"]) != _normalize_location(cmd, location):
raise ResourceNotFoundError('Container app {} is not in location {}.'.format(name, location))
if environment and (_get_name(environment) != _get_name(app["properties"]["managedEnvironmentId"])):
if environment and (_get_name(environment) != _get_name(app["properties"]["environmentId"])):
raise ResourceNotFoundError('Container app {} is not under environment {}.'.format(name, environment))
custom_domains = safe_get(app, "properties", "configuration", "ingress", "customDomains", default=[])
except CLIError as e:
Expand Down Expand Up @@ -1591,7 +1591,7 @@ def _azure_monitor_quickstart(cmd, name, resource_group_name, storage_account, l
logger.warning("Storage accounts only accepted for Azure Monitor logs destination. Ignoring storage account value.")
return
if not storage_account:
logger.warning("Azure monitor must be set up manually. Run `az monitor diagnostic-settings create --name mydiagnosticsettings --resource myManagedEnvironmentId --storage-account myStorageAccountId --logs myJsonLogSettings` to set up Azure Monitor diagnostic settings on your storage account.")
logger.warning("Azure monitor must be set up manually. Run `az monitor diagnostic-settings create --name mydiagnosticsettings --resource myEnvironmentId --storage-account myStorageAccountId --logs myJsonLogSettings` to set up Azure Monitor diagnostic settings on your storage account.")
return

from azure.cli.command_modules.monitor.operations.diagnostics_settings import create_diagnostics_settings
Expand Down
20 changes: 12 additions & 8 deletions src/containerapp/azext_containerapp/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,18 @@ def process_loaded_yaml(yaml_containerapp):
if not yaml_containerapp.get('properties'):
yaml_containerapp['properties'] = {}

nested_properties = ["provisioningState", "managedEnvironmentId", "latestRevisionName", "latestRevisionFqdn",
nested_properties = ["provisioningState", "managedEnvironmentId", "environmentId", "latestRevisionName", "latestRevisionFqdn",
"customDomainVerificationId", "configuration", "template", "outboundIPAddresses"]
for nested_property in nested_properties:
tmp = yaml_containerapp.get(nested_property)
if tmp:
yaml_containerapp['properties'][nested_property] = tmp
del yaml_containerapp[nested_property]

if "managedEnvironmentId" in yaml_containerapp['properties']:
yaml_containerapp['properties']["environmentId"] = yaml_containerapp['properties']['managedEnvironmentId']
del yaml_containerapp['properties']['managedEnvironmentId']

return yaml_containerapp


Expand Down Expand Up @@ -257,10 +261,10 @@ def create_containerapp_yaml(cmd, name, resource_group_name, file_name, no_wait=
_remove_readonly_attributes(containerapp_def)

# Validate managed environment
if not containerapp_def["properties"].get('managedEnvironmentId'):
raise RequiredArgumentMissingError('managedEnvironmentId is required. This can be retrieved using the `az containerapp env show -g MyResourceGroup -n MyContainerappEnvironment --query id` command. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')
if not containerapp_def["properties"].get('environmentId'):
raise RequiredArgumentMissingError('environmentId is required. This can be retrieved using the `az containerapp env show -g MyResourceGroup -n MyContainerappEnvironment --query id` command. Please see https://aka.ms/azure-container-apps-yaml for a valid containerapps YAML spec.')

env_id = containerapp_def["properties"]['managedEnvironmentId']
env_id = containerapp_def["properties"]['environmentId']
env_name = None
env_rg = None
env_info = None
Expand All @@ -270,7 +274,7 @@ def create_containerapp_yaml(cmd, name, resource_group_name, file_name, no_wait=
env_name = parsed_managed_env['name']
env_rg = parsed_managed_env['resource_group']
else:
raise ValidationError('Invalid managedEnvironmentId specified. Environment not found')
raise ValidationError('Invalid environmentId specified. Environment not found')

try:
env_info = ManagedEnvironmentClient.show(cmd=cmd, resource_group_name=env_rg, name=env_name)
Expand Down Expand Up @@ -529,7 +533,7 @@ def create_containerapp(cmd,
containerapp_def = ContainerAppModel
containerapp_def["location"] = location
containerapp_def["identity"] = identity_def
containerapp_def["properties"]["managedEnvironmentId"] = managed_env
containerapp_def["properties"]["environmentId"] = managed_env
containerapp_def["properties"]["configuration"] = config_def
containerapp_def["properties"]["template"] = template_def
containerapp_def["tags"] = tags
Expand Down Expand Up @@ -974,9 +978,9 @@ def list_containerapp(cmd, resource_group_name=None, managed_env=None):
env_name = parse_resource_id(managed_env)["name"].lower()
if "resource_group" in parse_resource_id(managed_env):
ManagedEnvironmentClient.show(cmd, parse_resource_id(managed_env)["resource_group"], parse_resource_id(managed_env)["name"])
containerapps = [c for c in containerapps if c["properties"]["managedEnvironmentId"].lower() == managed_env.lower()]
containerapps = [c for c in containerapps if c["properties"]["environmentId"].lower() == managed_env.lower()]
else:
containerapps = [c for c in containerapps if parse_resource_id(c["properties"]["managedEnvironmentId"])["name"].lower() == env_name]
containerapps = [c for c in containerapps if parse_resource_id(c["properties"]["environmentId"])["name"].lower() == env_name]

return containerapps
except CLIError as e:
Expand Down
Loading