Repository: Azure/azure-cli-extensions

Issue:
Azure Blueprint Artifact Update
Hi,

Going through the Azure CLI for using the Blueprint module, I see that you can add a --depends-on to a specific artifact. However, the CLI doesn't seem to support removing this property or setting it to be empty: []. When you try to set the artifact's "dependsOn" property to empty or "", it gives an error when trying to publish the new blueprint. The only way to fix this, that I have found so far, is by exporting the entire Blueprint with artifacts using Powershell and removing the "dependsOn" property manually inside of the artifact file. Then publishing a new version works as expected.

Is there any documentation to direct me in the right direction? I can't seem to find anything, and I would prefer to use the Azure CLI if possible rather than having to use both. Thank you!

V/r

---
#### Document Details

⚠ *Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.*

* ID: 47abba92-7835-67eb-8d1d-4c6a812ddd6d
* Version Independent ID: de3d0485-5660-44d7-8c80-7f5843a66fde
* Content: [az blueprint artifact template](https://docs.microsoft.com/en-us/cli/azure/ext/blueprint/blueprint/artifact/template?view=azure-cli-latest#ext_blueprint_az_blueprint_artifact_template_update)
* Content Source: [latest/docs-ref-autogen/ext/blueprint/blueprint/artifact/template.yml](https://github.com/MicrosoftDocs/azure-docs-cli/blob/master/latest/docs-ref-autogen/ext/blueprint/blueprint/artifact/template.yml)
* GitHub Login: @rloutlaw
* Microsoft Alias: **routlaw**


Discussion:
hi @fengzhou-msft could you pls help to look at the issue? thanks

Resolving patch:
diff --git a/src/blueprint/azext_blueprint/_params.py b/src/blueprint/azext_blueprint/_params.py
--- a/src/blueprint/azext_blueprint/_params.py
+++ b/src/blueprint/azext_blueprint/_params.py
@@ -113,7 +113,7 @@ def load_arguments(self, _):
         c.argument('artifact_name', help='A unique name of this resource group artifact.')
         c.argument('display_name', help='Display name of this resource group artifact.')
         c.argument('description', help='Description of the blueprint artifact.')
-        c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
+        c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
         c.argument('tags', tags_type, arg_group='Resource Group', help='Tags to be assigned to this resource group.')
 
     with self.argument_context('blueprint resource-group remove') as c:
@@ -142,7 +142,7 @@ def load_arguments(self, _):
         c.argument('artifact_name', help='Name of the blueprint artifact.')
         c.argument('display_name', help='DisplayName of this artifact.')
         c.argument('description', help='Description of the blueprint artifact.')
-        c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
+        c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
         c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
         c.argument('parameters', arg_type=parameter_type, help='Parameters for policy assignment artifact. It can be a JSON string or JSON file path.')
 
@@ -161,7 +161,7 @@ def load_arguments(self, _):
         c.argument('artifact_name', help='Name of the blueprint artifact.')
         c.argument('display_name', help='DisplayName of this artifact.')
         c.argument('description', help='Description of the blueprint artifact.')
-        c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
+        c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
         c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
 
     with self.argument_context('blueprint artifact template create') as c:
@@ -179,7 +179,7 @@ def load_arguments(self, _):
         c.argument('artifact_name', help='Name of the blueprint artifact.')
         c.argument('display_name', help='DisplayName of this artifact.')
         c.argument('description', help='Description of the blueprint artifact.')
-        c.argument('depends_on', nargs='+', help='Artifacts which need to be deployed before the specified artifact.')
+        c.argument('depends_on', nargs='*', help="Artifacts which need to be deployed before the specified artifact. Use '--depends-on' with no values to remove dependencies.")
         c.argument('resource_group_art', help='Name of the resource group artifact to which the policy will be assigned.')
         c.argument('parameters', arg_type=parameter_type, help='Parameters for ARM template artifact. It can be a JSON string or JSON file path.')
         c.argument('template', arg_type=template_type)
diff --git a/src/blueprint/azext_blueprint/custom.py b/src/blueprint/azext_blueprint/custom.py
--- a/src/blueprint/azext_blueprint/custom.py
+++ b/src/blueprint/azext_blueprint/custom.py
@@ -210,7 +210,7 @@ def update_blueprint_resource_group(cmd,
     if description is not None:
         resource_group['description'] = description  # str
     if depends_on is not None:
-        resource_group['depends_on'] = depends_on
+        resource_group['depends_on'] = _process_depends_on_for_update(depends_on)
     if tags is not None:
         resource_group['tags'] = tags
 
@@ -298,7 +298,7 @@ def update_blueprint_artifact_policy(cmd,
     if description is not None:
         body['description'] = description
     if depends_on is not None:
-        body['depends_on'] = depends_on
+        body['depends_on'] = _process_depends_on_for_update(depends_on)
 
     return client.create_or_update(scope=scope,
                                    blueprint_name=blueprint_name,
@@ -360,7 +360,7 @@ def update_blueprint_artifact_role(cmd,
     if description is not None:
         body['description'] = description
     if depends_on is not None:
-        body['depends_on'] = depends_on
+        body['depends_on'] = _process_depends_on_for_update(depends_on)
 
     return client.create_or_update(scope=scope,
                                    blueprint_name=blueprint_name,
@@ -424,7 +424,7 @@ def update_blueprint_artifact_template(cmd,
     if description is not None:
         body['description'] = description
     if depends_on is not None:
-        body['depends_on'] = depends_on
+        body['depends_on'] = _process_depends_on_for_update(depends_on)
 
     return client.create_or_update(scope=scope,
                                    blueprint_name=blueprint_name,
@@ -627,3 +627,11 @@ def wait_for_blueprint_assignment(cmd, client, assignment_name, management_group
 
 def who_is_blueprint_blueprint_assignment(cmd, client, assignment_name, management_group=None, subscription=None, scope=None):
     return client.who_is_blueprint(scope=scope, assignment_name=assignment_name)
+
+
+def _process_depends_on_for_update(depends_on):
+    if not depends_on:  # [] for case: --depends-on
+        return None
+    if not any(depends_on):  # [''] for case: --depends-on= /--depends-on ""
+        return None
+    return depends_on
diff --git a/src/blueprint/setup.py b/src/blueprint/setup.py
--- a/src/blueprint/setup.py
+++ b/src/blueprint/setup.py
@@ -16,7 +16,7 @@
 
 # TODO: Confirm this is the right version number you want and it matches your
 # HISTORY.rst entry.
-VERSION = '0.2.0'
+VERSION = '0.2.1'
 
 # The full list of classifiers is available at
 # https://pypi.python.org/pypi?%3Aaction=list_classifiers


Test patch: