Skip to content

Remove-ObjectProperty and Add-ObjectProperty does not support indexing notation on path #439

@jikuja

Description

@jikuja

Describe the bug
I was deploying following content:

pipeline:

// code available by request

trigger:

{
	"name": "trigger",
	"properties": {
		"annotations": [],
		"runtimeState": "Started",
		"pipelines": [
			{
				"pipelineReference": {
					"referenceName": "pipeline",
					"type": "PipelineReference"
				},
				"parameters": {
					"filePath": "@triggerBody().folderPath",
					"fileName": "@triggerBody().fileName"
				}
			}
		],
		"type": "BlobEventsTrigger",
		"typeProperties": {
			"blobPathBeginsWith": "redacted",
			"blobPathEndsWith": "redacted.xlsx",
			"ignoreEmptyBlobs": true,
			"scope": "/subscriptions/redacted/resourceGroups/redacted-storage-dev-rg/providers/Microsoft.Storage/storageAccounts/redacted",
			"events": [
				"Microsoft.Storage.BlobCreated"
			]
		}
	}
}

parameter file:

# trigger
trigger,trigger,typeProperties.scope, "xx"
trigger,trigger,+pipelines[0].parameters.refreshDataset, "true"
trigger,trigger,-pipelines[0].parameters.fileName

Trigger parameters did not update according to my parameters.

With dry-run result are following:

$adf = publish-AdfV2FromJson -RootFolder "." -ResourceGroupName tekdata-datafactory-prod-rg -DataFactoryName tekdata-datafactory-prod-df -Location westeurope -Stage ./parameters-prod.csv -Option $opt -DryRun
($adf.Triggers | Where-Object {$_.Name -eq "trigger"}).Body.properties | ConvertTo-Json -Depth 99

results:

{                                                                                                   
  "annotations": [],
  "runtimeState": "Started",
  "pipelines": [
    {
      "pipelineReference": {
        "referenceName": "pipeline",
        "type": "PipelineReference"
      },
      "parameters": {
        "filePath": "@triggerBody().folderPath",
        "fileName": "@triggerBody().fileName"
      }
    }
  ],
  "type": "BlobEventsTrigger",
  "typeProperties": {
    "blobPathBeginsWith": "redacted",
    "blobPathEndsWith": "redacted.xlsx",
    "ignoreEmptyBlobs": true,
    "scope": "xx",
    "events": [
      "Microsoft.Storage.BlobCreated"
    ]
  },
  "pipelines[0]": {
    "parameters": {
      "refreshDataset": "true"
    }
  }
}

From result we can see that indexing notation was not resolved, instead [0] is being used as part of $root on

$obj | Add-Member -NotePropertyName $root -NotePropertyValue $value

Remove-ObjectProperty have similar issue. Update-ObjectProperty works because of the Invoke-Expressions usage.

Expected behaviour
Indexing notation on parameter file paths should work.

I could not see any mentions about this kind of limitation on documentation.

Version of PowerShell module of:

  • 1.11.2
  • Code analysis from master branch

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions