Skip to content

Commit 24dec62

Browse files
author
Atharva
committed
Added change
1 parent e62546b commit 24dec62

File tree

1 file changed

+9
-2
lines changed
  • src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target

1 file changed

+9
-2
lines changed

src/workload-orchestration/azext_workload_orchestration/aaz/latest/workload_orchestration/target/_create.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
# flake8: noqa
1010

1111
from azure.cli.core.aaz import *
12+
from azure.cli.core.azclierror import CLIInternalError
1213

1314

1415
@register_command(
@@ -71,7 +72,6 @@ def _build_arguments_schema(cls, *args, **kwargs):
7172
options=["--context-id"],
7273
arg_group="Properties",
7374
help="ArmId of Context",
74-
required=True,
7575
)
7676
_args_schema.description = AAZStrArg(
7777
options=["--description"],
@@ -166,7 +166,14 @@ def _execute_operations(self):
166166

167167
@register_callback
168168
def pre_operations(self):
169-
pass
169+
# If context_id is not provided, try to get it from config
170+
if not self.ctx.args.context_id:
171+
context_id = self.ctx.cli_ctx.config.get('workload_orchestration', 'context_id')
172+
print("Context ID" , context_id)
173+
if context_id:
174+
self.ctx.args.context_id = context_id
175+
else:
176+
raise CLIInternalError("No context-id provided and no default context found. Please provide --context-id or use 'az workload-orchestration context use' to set a default context.")
170177

171178
@register_callback
172179
def post_operations(self):

0 commit comments

Comments
 (0)