Skip to content

Commit 11932b1

Browse files
committed
Ensure that args/cmd arguments are passed to CP even without image
1 parent 55b9e97 commit 11932b1

File tree

3 files changed

+2607
-2
lines changed

3 files changed

+2607
-2
lines changed

src/azure-cli/azure/cli/command_modules/containerapp/custom.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,12 @@ def start_containerappsjob(cmd,
15551555

15561556
template_def = None
15571557

1558-
if image is not None:
1558+
# Check if any container override parameters are provided
1559+
has_container_overrides = (image is not None or container_name is not None or
1560+
env_vars is not None or startup_command is not None or
1561+
args is not None or cpu is not None or memory is not None)
1562+
1563+
if has_container_overrides:
15591564
template_def = JobExecutionTemplateModel
15601565
container_def = ContainerModel
15611566
resources_def = None
@@ -1565,7 +1570,25 @@ def start_containerappsjob(cmd,
15651570
resources_def["memory"] = memory
15661571

15671572
container_def["name"] = container_name if container_name else name
1568-
container_def["image"] = image if not is_registry_msi_system(registry_identity) else HELLO_WORLD_IMAGE
1573+
1574+
# If no image is provided, fetch the existing job's image
1575+
if image is not None:
1576+
container_def["image"] = image if not is_registry_msi_system(registry_identity) else HELLO_WORLD_IMAGE
1577+
else:
1578+
# Fetch the existing job definition to get the default image
1579+
try:
1580+
containerappjob_def = ContainerAppsJobClient.show(cmd=cmd, resource_group_name=resource_group_name, name=name)
1581+
except Exception as e:
1582+
handle_raw_exception(e)
1583+
1584+
if not containerappjob_def:
1585+
raise ResourceNotFoundError("The containerapp job '{}' does not exist".format(name))
1586+
1587+
existing_image = safe_get(containerappjob_def, "properties", "template", "containers", default=[{}])[0].get("image")
1588+
if not existing_image:
1589+
raise ValidationError("Could not find an existing image for the containerapp job '{}'. Please specify --image.".format(name))
1590+
container_def["image"] = existing_image
1591+
15691592
if env_vars is not None:
15701593
container_def["env"] = parse_env_var_flags(env_vars)
15711594
if startup_command is not None:

0 commit comments

Comments
 (0)