Azure-Player / azure.datafactory.tools

Tools for deploying Data Factory (v2) in Microsoft Azure
https://azureplayer.net/adftools
MIT License
209 stars 69 forks source link

AdfObjectName issues with fetching and validating object #322

Closed chetanm-bw closed 1 year ago

chetanm-bw commented 1 year ago

Describe the bug

While using Publish-AdfV2FromJson , it uses below method. Below method fails abruptly and not able to pull out object name details.

private/AdfObjectName.class.ps1

AdfObjectName ([string] $FullName) { $m = [regex]::matches($FullName, '([a-zA-Z]+).([a-zA-Z 0-9-_]+)@?(.*)') if ($m.Success -eq $false) { throw "ADFT0028: Expected format of name for 'FullName' input parameter is: objectType.objectName[@folderName]" }

    $this.Type = $m.Groups[1].Value
    $this.Name = $m.Groups[2].Value
    $this.Folder = $m.Groups[3].Value
}

To Reproduce If dependent object are missing ( e.g. Linked service or dataset related to Pipeline , Dataflow )

Your script here

Expected behaviour

Should report and log issue with object which is causing trouble.

Screenshots

Please find below log details

2023-05-30T12:47:04.3810705Z The property 'Success' cannot be found on this object. Verify that the property exists. 2023-05-30T12:47:04.3811350Z At C:\Program Files\WindowsPowerShell\Modules\azure.datafactory.tools\1.4.0\private\AdfObjectName.class.ps1:24 char:13 2023-05-30T12:47:04.3811816Z + if ($m.Success -eq $false) { 2023-05-30T12:47:04.3812129Z + ~~~~~ 2023-05-30T12:47:04.3812468Z + CategoryInfo : InvalidOperation: (:) [], RuntimeException 2023-05-30T12:47:04.3812851Z + FullyQualifiedErrorId : PropertyNotFoundStrict

Version of PowerShell module of:

Provide all files to reproduce the issue

chetanm-bw commented 1 year ago

After enabling Verbose , found this issue is causing for scenarios wherein , there are missing reference object ( e.g. Linked Service , Dataset etc. )

Ideally if we are doing selecting deployment then , if there are issues in another pipeline / folder , all those issues should get ignore and object which we have selected for deployment, if those doesn't have any issues / validation error then those object should get deployed.

NowinskiK commented 1 year ago

Thanks for investigating. Could you add example file(s)? For validation there is a separate method, which probably was not used in your case?

chetanm-bw commented 1 year ago

For validation we have added Test-AdfCode -RootFolder "$RootFolder" which is helping and reporting missing dependency issues but I think Publish-AdfV2FromJson eventually tries to read all ADF object from root folder.

Write-Host "STEP: Reading Azure Data Factory from JSON files..." $adf = Import-AdfFromFolder -FactoryName $DataFactoryName -RootFolder "$RootFolder"

wherein it fails at point wherein it tries to identify reference object.

Discover all referenced objects

    $refs = Get-ReferencedObjects -obj $o

which eventually calls AdfObjectName.class.ps1

AdfObjectName ([string] $FullName)

Question , if we are doing selecting deployment ( by doing $adf.GetObjectsByFolderName("$Application") ) ideally if there are error in other folder / object , we should be able to ignore it ,is that something possible ?

NowinskiK commented 1 year ago

This is unexpected situation, so probably no flags help in this case, but try: [Boolean] FailsWhenPathNotFound - indicates whether missing paths fails the script. (default: true)

Could you add example file(s) to investigate this deeper in spare time?