Skip to content

Commit 02b8437

Browse files
authored
Merge pull request #169 from Azure-Player/v2.1
Updated PS module to ver.1.11.1
2 parents fb16c5b + fa4ecce commit 02b8437

9 files changed

Lines changed: 106 additions & 26 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,12 +190,12 @@ The purpose of this task is to ensure such checking. It works exactly the same a
190190

191191
# Related modules
192192
These tasks include the following modules:
193-
- [azure.datafactory.tools - ver.1.11.0](https://www.powershellgallery.com/packages/azure.datafactory.tools/1.11.0)
193+
- [azure.datafactory.tools - ver.1.11.1](https://www.powershellgallery.com/packages/azure.datafactory.tools/1.11.1)
194194
- [Az.DataFactory - ver.1.18.8](https://www.powershellgallery.com/packages/Az.DataFactory/1.18.8)
195195

196196
# History
197197
## Version 2.*
198-
- 30 Oct 2024 - v.2.1 - Incremental state is no longer save into Global Parameter of ADF, but now it's store in provided Storage Account #374
198+
- 06 Nov 2024 - v.2.1 - Incremental state is no longer save into Global Parameter of ADF, but now it's store in provided Storage Account #374
199199
- 14 Jun 2024 - v.2.0 - Related Az.* modules must be installed on DevOps Agent (no longer belongs to tasks)
200200
- Support for Service Connection using **Workload Identity Federation Authentication** in Azure DevOps (#154)
201201
- Test Connection Task is no longer Preview. ClientID & Secret fields are optional for SPN auth.

buildDataFactoryTask/buildDataFactoryTaskV1/ps_modules/azure.datafactory.tools/azure.datafactory.tools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'azure.datafactory.tools.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.11.0'
15+
ModuleVersion = '1.11.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

buildDataFactoryTask/buildDataFactoryTaskV1/ps_modules/azure.datafactory.tools/private/DeploymentState.class.ps1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ function Get-StateFromStorage {
6161
$FileRef = $storageContainer.CloudBlobContainer.GetBlockBlobReference("$folder$DataFactoryName.$Suffix")
6262
if ($FileRef.Exists()) {
6363
$FileContent = $FileRef.DownloadText()
64-
#Write-Host $FileContent -BackgroundColor Blue
64+
# $FileRef.DownloadText() | Set-Content $Suffix
65+
# $FileContent = Get-Content $Suffix -Encoding 'UTF8'
66+
# foreach ($line in $FileContent) {
67+
# Write-Debug $line
68+
# }
6569
$json = $FileContent | ConvertFrom-Json
6670
$ds.Deployed = Convert-PSObjectToHashtable $json.Deployed
6771
$ds.adftoolsVer = $json.adftoolsVer
@@ -84,15 +88,18 @@ function Set-StateToStorage {
8488
[Parameter(Mandatory)] $LocationUri
8589
)
8690

87-
$Suffix = "adftools_deployment_state.json"
91+
$localFile = "adftools_deployment_state.json"
8892
$dsjson = ConvertTo-Json $ds -Depth 5
8993
Write-Verbose "--- Deployment State: ---`r`n $dsjson"
9094

91-
Set-Content -Path $Suffix -Value $dsjson -Encoding UTF8
95+
$fullFilePath = Save-ContentUTF8 -Path $localFile -Value $dsjson
96+
$isExist = Test-Path $fullFilePath
97+
Write-Host "Tested file location: $fullFilePath (result: $isExist)"
98+
Write-Host "Current location: $(Get-Location)"
9299
$storageAccountName = Get-StorageAccountNameFromUri $LocationUri
93100
$storageContext = New-AzStorageContext -UseConnectedAccount -StorageAccountName $storageAccountName
94-
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$Suffix")
95-
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $Suffix -Context $storageContext -Force
101+
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$localFile")
102+
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $fullFilePath -Context $storageContext -Force
96103

97104
Write-Host "Deployment State saved to storage: $($r.BlobClient.Uri)"
98105
}
@@ -103,3 +110,16 @@ function Get-StorageAccountNameFromUri($uri) {
103110
return $accountName
104111
}
105112

113+
function Save-ContentUTF8($Path, $Value) {
114+
Write-Debug "Save-ContentUTF8::Begin: $Path $Value"
115+
$fullPath = Resolve-NonExistPath -Path $Path #.NET function (WriteAllLines) requires full path, otherwise "default" location != PS default location
116+
Write-Debug "Save-ContentUTF8::fullPath: $fullPath"
117+
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False # with BOM-less
118+
[System.IO.File]::WriteAllLines($fullPath, $Value, $Utf8NoBomEncoding)
119+
Write-Debug "Save-ContentUTF8::End: Saved UTF8 file to location: $Path"
120+
return $fullPath
121+
}
122+
123+
function Resolve-NonExistPath($Path) {
124+
return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
125+
}

deployAdfFromArmTask/deployAdfFromArmTaskV1/ps_modules/azure.datafactory.tools/azure.datafactory.tools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'azure.datafactory.tools.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.11.0'
15+
ModuleVersion = '1.11.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

deployAdfFromArmTask/deployAdfFromArmTaskV1/ps_modules/azure.datafactory.tools/private/DeploymentState.class.ps1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ function Get-StateFromStorage {
6161
$FileRef = $storageContainer.CloudBlobContainer.GetBlockBlobReference("$folder$DataFactoryName.$Suffix")
6262
if ($FileRef.Exists()) {
6363
$FileContent = $FileRef.DownloadText()
64-
#Write-Host $FileContent -BackgroundColor Blue
64+
# $FileRef.DownloadText() | Set-Content $Suffix
65+
# $FileContent = Get-Content $Suffix -Encoding 'UTF8'
66+
# foreach ($line in $FileContent) {
67+
# Write-Debug $line
68+
# }
6569
$json = $FileContent | ConvertFrom-Json
6670
$ds.Deployed = Convert-PSObjectToHashtable $json.Deployed
6771
$ds.adftoolsVer = $json.adftoolsVer
@@ -84,15 +88,18 @@ function Set-StateToStorage {
8488
[Parameter(Mandatory)] $LocationUri
8589
)
8690

87-
$Suffix = "adftools_deployment_state.json"
91+
$localFile = "adftools_deployment_state.json"
8892
$dsjson = ConvertTo-Json $ds -Depth 5
8993
Write-Verbose "--- Deployment State: ---`r`n $dsjson"
9094

91-
Set-Content -Path $Suffix -Value $dsjson -Encoding UTF8
95+
$fullFilePath = Save-ContentUTF8 -Path $localFile -Value $dsjson
96+
$isExist = Test-Path $fullFilePath
97+
Write-Host "Tested file location: $fullFilePath (result: $isExist)"
98+
Write-Host "Current location: $(Get-Location)"
9299
$storageAccountName = Get-StorageAccountNameFromUri $LocationUri
93100
$storageContext = New-AzStorageContext -UseConnectedAccount -StorageAccountName $storageAccountName
94-
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$Suffix")
95-
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $Suffix -Context $storageContext -Force
101+
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$localFile")
102+
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $fullFilePath -Context $storageContext -Force
96103

97104
Write-Host "Deployment State saved to storage: $($r.BlobClient.Uri)"
98105
}
@@ -103,3 +110,16 @@ function Get-StorageAccountNameFromUri($uri) {
103110
return $accountName
104111
}
105112

113+
function Save-ContentUTF8($Path, $Value) {
114+
Write-Debug "Save-ContentUTF8::Begin: $Path $Value"
115+
$fullPath = Resolve-NonExistPath -Path $Path #.NET function (WriteAllLines) requires full path, otherwise "default" location != PS default location
116+
Write-Debug "Save-ContentUTF8::fullPath: $fullPath"
117+
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False # with BOM-less
118+
[System.IO.File]::WriteAllLines($fullPath, $Value, $Utf8NoBomEncoding)
119+
Write-Debug "Save-ContentUTF8::End: Saved UTF8 file to location: $Path"
120+
return $fullPath
121+
}
122+
123+
function Resolve-NonExistPath($Path) {
124+
return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
125+
}

deployDataFactoryTask/deployDataFactoryTaskV2/ps_modules/azure.datafactory.tools/azure.datafactory.tools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'azure.datafactory.tools.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.11.0'
15+
ModuleVersion = '1.11.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

deployDataFactoryTask/deployDataFactoryTaskV2/ps_modules/azure.datafactory.tools/private/DeploymentState.class.ps1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ function Get-StateFromStorage {
6161
$FileRef = $storageContainer.CloudBlobContainer.GetBlockBlobReference("$folder$DataFactoryName.$Suffix")
6262
if ($FileRef.Exists()) {
6363
$FileContent = $FileRef.DownloadText()
64-
#Write-Host $FileContent -BackgroundColor Blue
64+
# $FileRef.DownloadText() | Set-Content $Suffix
65+
# $FileContent = Get-Content $Suffix -Encoding 'UTF8'
66+
# foreach ($line in $FileContent) {
67+
# Write-Debug $line
68+
# }
6569
$json = $FileContent | ConvertFrom-Json
6670
$ds.Deployed = Convert-PSObjectToHashtable $json.Deployed
6771
$ds.adftoolsVer = $json.adftoolsVer
@@ -84,15 +88,18 @@ function Set-StateToStorage {
8488
[Parameter(Mandatory)] $LocationUri
8589
)
8690

87-
$Suffix = "adftools_deployment_state.json"
91+
$localFile = "adftools_deployment_state.json"
8892
$dsjson = ConvertTo-Json $ds -Depth 5
8993
Write-Verbose "--- Deployment State: ---`r`n $dsjson"
9094

91-
Set-Content -Path $Suffix -Value $dsjson -Encoding UTF8
95+
$fullFilePath = Save-ContentUTF8 -Path $localFile -Value $dsjson
96+
$isExist = Test-Path $fullFilePath
97+
Write-Host "Tested file location: $fullFilePath (result: $isExist)"
98+
Write-Host "Current location: $(Get-Location)"
9299
$storageAccountName = Get-StorageAccountNameFromUri $LocationUri
93100
$storageContext = New-AzStorageContext -UseConnectedAccount -StorageAccountName $storageAccountName
94-
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$Suffix")
95-
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $Suffix -Context $storageContext -Force
101+
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$localFile")
102+
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $fullFilePath -Context $storageContext -Force
96103

97104
Write-Host "Deployment State saved to storage: $($r.BlobClient.Uri)"
98105
}
@@ -103,3 +110,16 @@ function Get-StorageAccountNameFromUri($uri) {
103110
return $accountName
104111
}
105112

113+
function Save-ContentUTF8($Path, $Value) {
114+
Write-Debug "Save-ContentUTF8::Begin: $Path $Value"
115+
$fullPath = Resolve-NonExistPath -Path $Path #.NET function (WriteAllLines) requires full path, otherwise "default" location != PS default location
116+
Write-Debug "Save-ContentUTF8::fullPath: $fullPath"
117+
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False # with BOM-less
118+
[System.IO.File]::WriteAllLines($fullPath, $Value, $Utf8NoBomEncoding)
119+
Write-Debug "Save-ContentUTF8::End: Saved UTF8 file to location: $Path"
120+
return $fullPath
121+
}
122+
123+
function Resolve-NonExistPath($Path) {
124+
return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
125+
}

testLinkedServiceTask/testLinkedServiceTaskV2/ps_modules/azure.datafactory.tools/azure.datafactory.tools.psd1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
RootModule = 'azure.datafactory.tools.psm1'
1313

1414
# Version number of this module.
15-
ModuleVersion = '1.11.0'
15+
ModuleVersion = '1.11.1'
1616

1717
# Supported PSEditions
1818
# CompatiblePSEditions = @()

testLinkedServiceTask/testLinkedServiceTaskV2/ps_modules/azure.datafactory.tools/private/DeploymentState.class.ps1

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@ function Get-StateFromStorage {
6161
$FileRef = $storageContainer.CloudBlobContainer.GetBlockBlobReference("$folder$DataFactoryName.$Suffix")
6262
if ($FileRef.Exists()) {
6363
$FileContent = $FileRef.DownloadText()
64-
#Write-Host $FileContent -BackgroundColor Blue
64+
# $FileRef.DownloadText() | Set-Content $Suffix
65+
# $FileContent = Get-Content $Suffix -Encoding 'UTF8'
66+
# foreach ($line in $FileContent) {
67+
# Write-Debug $line
68+
# }
6569
$json = $FileContent | ConvertFrom-Json
6670
$ds.Deployed = Convert-PSObjectToHashtable $json.Deployed
6771
$ds.adftoolsVer = $json.adftoolsVer
@@ -84,15 +88,18 @@ function Set-StateToStorage {
8488
[Parameter(Mandatory)] $LocationUri
8589
)
8690

87-
$Suffix = "adftools_deployment_state.json"
91+
$localFile = "adftools_deployment_state.json"
8892
$dsjson = ConvertTo-Json $ds -Depth 5
8993
Write-Verbose "--- Deployment State: ---`r`n $dsjson"
9094

91-
Set-Content -Path $Suffix -Value $dsjson -Encoding UTF8
95+
$fullFilePath = Save-ContentUTF8 -Path $localFile -Value $dsjson
96+
$isExist = Test-Path $fullFilePath
97+
Write-Host "Tested file location: $fullFilePath (result: $isExist)"
98+
Write-Host "Current location: $(Get-Location)"
9299
$storageAccountName = Get-StorageAccountNameFromUri $LocationUri
93100
$storageContext = New-AzStorageContext -UseConnectedAccount -StorageAccountName $storageAccountName
94-
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$Suffix")
95-
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $Suffix -Context $storageContext -Force
101+
$blob = [Microsoft.Azure.Storage.Blob.CloudBlob]::new("$LocationUri/$DataFactoryName.$localFile")
102+
$r = Set-AzStorageBlobContent -ClientTimeoutPerRequest 5 -ServerTimeoutPerRequest 5 -CloudBlob $blob -File $fullFilePath -Context $storageContext -Force
96103

97104
Write-Host "Deployment State saved to storage: $($r.BlobClient.Uri)"
98105
}
@@ -103,3 +110,16 @@ function Get-StorageAccountNameFromUri($uri) {
103110
return $accountName
104111
}
105112

113+
function Save-ContentUTF8($Path, $Value) {
114+
Write-Debug "Save-ContentUTF8::Begin: $Path $Value"
115+
$fullPath = Resolve-NonExistPath -Path $Path #.NET function (WriteAllLines) requires full path, otherwise "default" location != PS default location
116+
Write-Debug "Save-ContentUTF8::fullPath: $fullPath"
117+
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False # with BOM-less
118+
[System.IO.File]::WriteAllLines($fullPath, $Value, $Utf8NoBomEncoding)
119+
Write-Debug "Save-ContentUTF8::End: Saved UTF8 file to location: $Path"
120+
return $fullPath
121+
}
122+
123+
function Resolve-NonExistPath($Path) {
124+
return $ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path)
125+
}

0 commit comments

Comments
 (0)