Skip to content

Commit

Permalink
AzureRM PS module deprecation (#19423)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
doomkit authored Jan 22, 2024
1 parent a27cbab commit 5e0b1b9
Show file tree
Hide file tree
Showing 151 changed files with 9,432 additions and 514 deletions.
36 changes: 32 additions & 4 deletions Tasks/AzureCloudPowerShellDeploymentV1/Utility.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
function Get-SingleFile($files, $pattern)
$featureFlags = @{
retireAzureRM = [System.Convert]::ToBoolean($env:RETIRE_AZURERM_POWERSHELL_MODULE)
}

function Get-SingleFile($files, $pattern)
{
if ($files -is [system.array])
{
Expand Down Expand Up @@ -57,12 +61,29 @@ function Get-AzureStoragePrimaryKey($storageAccount, [bool]$isArm)
{
if ($isArm)
{
$storageAccountResource = Get-AzureRmResource | where-object { $_.Name -eq $storageAccount -and $_.ResourceType -eq "Microsoft.Storage/storageAccounts" }
if ($featureFlags.retireAzureRM)
{
$storageAccountResource = Get-AzResource | where-object { $_.Name -eq $storageAccount -and $_.ResourceType -eq "Microsoft.Storage/storageAccounts" }
}
else
{
$storageAccountResource = Get-AzureRmResource | where-object { $_.Name -eq $storageAccount -and $_.ResourceType -eq "Microsoft.Storage/storageAccounts" }
}

if (!$storageAccountResource)
{
Write-Error -Message "Could not find resource $storageAccount that has a type of Microsoft.Storage/storageAccounts"
}
$storageAccountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccountResource.ResourceGroupName -Name $storageAccount

if ($featureFlags.retireAzureRM)
{
$storageAccountKeys = Get-AzStorageAccountKey -ResourceGroupName $storageAccountResource.ResourceGroupName -Name $storageAccount
}
else
{
$storageAccountKeys = Get-AzureRmStorageAccountKey -ResourceGroupName $storageAccountResource.ResourceGroupName -Name $storageAccount
}

if(!$storageAccountKeys)
{
Write-Error -Message "Could not retrieve storage account keys from storage account resource $Storage"
Expand Down Expand Up @@ -185,7 +206,14 @@ function Get-DiagnosticsExtensions($storageAccount, $extensionsPath, $storageAcc
{
try
{
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
if ($featureFlags.retireAzureRM)
{
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
}
else
{
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
}
Write-Host "New-AzureServiceDiagnosticsExtensionConfig -Role $role -StorageContext $StorageContext -DiagnosticsConfigurationPath $fullExtPath"
$wadconfig = New-AzureServiceDiagnosticsExtensionConfig -Role $role -StorageContext $StorageContext -DiagnosticsConfigurationPath $fullExtPath
}
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCloudPowerShellDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 226,
"Minor": 234,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 226,
"Minor": 234,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCloudPowerShellDeploymentV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 226,
"Minor": 234,
"Patch": 0
},
"demands": [
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureCloudPowerShellDeploymentV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 226,
"Minor": 234,
"Patch": 0
},
"demands": [
Expand Down
16 changes: 14 additions & 2 deletions Tasks/AzureFileCopyV1/AzureFileCopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ param()

Trace-VstsEnteringInvocation $MyInvocation

$featureFlags = @{
retireAzureRM = [System.Convert]::ToBoolean($env:RETIRE_AZURERM_POWERSHELL_MODULE)
}

# Get inputs for the task
$connectedServiceNameSelector = Get-VstsInput -Name ConnectedServiceNameSelector -Require
$sourcePath = Get-VstsInput -Name SourcePath -Require
Expand Down Expand Up @@ -168,7 +172,15 @@ try {
}
if(-not [string]::IsNullOrEmpty($outputStorageContainerSASToken))
{
$storageContainerSaSToken = New-AzureStorageContainerSASToken -Container $containerName -Context $storageContext -Permission r -ExpiryTime (Get-Date).AddHours($defaultSasTokenTimeOutInHours)
if ($featureFlags.retireAzureRM)
{
$storageContainerSaSToken = New-AzStorageContainerSASToken -Name $containerName -Context $storageContext -Permission r -ExpiryTime (Get-Date).AddHours($defaultSasTokenTimeOutInHours)
}
else
{
$storageContainerSaSToken = New-AzureStorageContainerSASToken -Container $containerName -Context $storageContext -Permission r -ExpiryTime (Get-Date).AddHours($defaultSasTokenTimeOutInHours)
}

Write-Host "##vso[task.setvariable variable=$outputStorageContainerSASToken;]$storageContainerSasToken"
}

Expand Down Expand Up @@ -221,4 +233,4 @@ try {
}
finally {
Disconnect-AzureAndClearContext -authScheme $connectionType -ErrorAction SilentlyContinue
}
}
Loading

0 comments on commit 5e0b1b9

Please sign in to comment.