Skip to content

Commit 5e0b1b9

Browse files
authored
AzureRM PS module deprecation (#19423)
* Migrate tasks using Az.Tools.Migration * Fix padding after migration * Bump tasks versions * Add FF switch * Add missing FF switch * Bump tasks versions (due to changes in Common) * update generated tasks * Fix typo * Update genearated task --------- Co-authored-by: v-kivlev <undefined>
1 parent a27cbab commit 5e0b1b9

File tree

151 files changed

+9432
-514
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

151 files changed

+9432
-514
lines changed

Diff for: Tasks/AzureCloudPowerShellDeploymentV1/Utility.ps1

+32-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
function Get-SingleFile($files, $pattern)
1+
$featureFlags = @{
2+
retireAzureRM = [System.Convert]::ToBoolean($env:RETIRE_AZURERM_POWERSHELL_MODULE)
3+
}
4+
5+
function Get-SingleFile($files, $pattern)
26
{
37
if ($files -is [system.array])
48
{
@@ -57,12 +61,29 @@ function Get-AzureStoragePrimaryKey($storageAccount, [bool]$isArm)
5761
{
5862
if ($isArm)
5963
{
60-
$storageAccountResource = Get-AzureRmResource | where-object { $_.Name -eq $storageAccount -and $_.ResourceType -eq "Microsoft.Storage/storageAccounts" }
64+
if ($featureFlags.retireAzureRM)
65+
{
66+
$storageAccountResource = Get-AzResource | where-object { $_.Name -eq $storageAccount -and $_.ResourceType -eq "Microsoft.Storage/storageAccounts" }
67+
}
68+
else
69+
{
70+
$storageAccountResource = Get-AzureRmResource | where-object { $_.Name -eq $storageAccount -and $_.ResourceType -eq "Microsoft.Storage/storageAccounts" }
71+
}
72+
6173
if (!$storageAccountResource)
6274
{
6375
Write-Error -Message "Could not find resource $storageAccount that has a type of Microsoft.Storage/storageAccounts"
6476
}
65-
$storageAccountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccountResource.ResourceGroupName -Name $storageAccount
77+
78+
if ($featureFlags.retireAzureRM)
79+
{
80+
$storageAccountKeys = Get-AzStorageAccountKey -ResourceGroupName $storageAccountResource.ResourceGroupName -Name $storageAccount
81+
}
82+
else
83+
{
84+
$storageAccountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccountResource.ResourceGroupName -Name $storageAccount
85+
}
86+
6687
if(!$storageAccountKeys)
6788
{
6889
Write-Error -Message "Could not retrieve storage account keys from storage account resource $Storage"
@@ -185,7 +206,14 @@ function Get-DiagnosticsExtensions($storageAccount, $extensionsPath, $storageAcc
185206
{
186207
try
187208
{
188-
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
209+
if ($featureFlags.retireAzureRM)
210+
{
211+
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
212+
}
213+
else
214+
{
215+
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
216+
}
189217
Write-Host "New-AzureServiceDiagnosticsExtensionConfig -Role $role -StorageContext $StorageContext -DiagnosticsConfigurationPath $fullExtPath"
190218
$wadconfig = New-AzureServiceDiagnosticsExtensionConfig -Role $role -StorageContext $StorageContext -DiagnosticsConfigurationPath $fullExtPath
191219
}

Diff for: Tasks/AzureCloudPowerShellDeploymentV1/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 1,
19-
"Minor": 226,
19+
"Minor": 234,
2020
"Patch": 0
2121
},
2222
"demands": [

Diff for: Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 1,
19-
"Minor": 226,
19+
"Minor": 234,
2020
"Patch": 0
2121
},
2222
"demands": [

Diff for: Tasks/AzureCloudPowerShellDeploymentV2/task.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 2,
19-
"Minor": 226,
19+
"Minor": 234,
2020
"Patch": 0
2121
},
2222
"demands": [

Diff for: Tasks/AzureCloudPowerShellDeploymentV2/task.loc.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"author": "Microsoft Corporation",
1717
"version": {
1818
"Major": 2,
19-
"Minor": 226,
19+
"Minor": 234,
2020
"Patch": 0
2121
},
2222
"demands": [

Diff for: Tasks/AzureFileCopyV1/AzureFileCopy.ps1

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@ param()
33

44
Trace-VstsEnteringInvocation $MyInvocation
55

6+
$featureFlags = @{
7+
retireAzureRM = [System.Convert]::ToBoolean($env:RETIRE_AZURERM_POWERSHELL_MODULE)
8+
}
9+
610
# Get inputs for the task
711
$connectedServiceNameSelector = Get-VstsInput -Name ConnectedServiceNameSelector -Require
812
$sourcePath = Get-VstsInput -Name SourcePath -Require
@@ -168,7 +172,15 @@ try {
168172
}
169173
if(-not [string]::IsNullOrEmpty($outputStorageContainerSASToken))
170174
{
171-
$storageContainerSaSToken = New-AzureStorageContainerSASToken -Container $containerName -Context $storageContext -Permission r -ExpiryTime (Get-Date).AddHours($defaultSasTokenTimeOutInHours)
175+
if ($featureFlags.retireAzureRM)
176+
{
177+
$storageContainerSaSToken = New-AzStorageContainerSASToken -Name $containerName -Context $storageContext -Permission r -ExpiryTime (Get-Date).AddHours($defaultSasTokenTimeOutInHours)
178+
}
179+
else
180+
{
181+
$storageContainerSaSToken = New-AzureStorageContainerSASToken -Container $containerName -Context $storageContext -Permission r -ExpiryTime (Get-Date).AddHours($defaultSasTokenTimeOutInHours)
182+
}
183+
172184
Write-Host "##vso[task.setvariable variable=$outputStorageContainerSASToken;]$storageContainerSasToken"
173185
}
174186

@@ -221,4 +233,4 @@ try {
221233
}
222234
finally {
223235
Disconnect-AzureAndClearContext -authScheme $connectionType -ErrorAction SilentlyContinue
224-
}
236+
}

0 commit comments

Comments
 (0)