Skip to content

Commit

Permalink
Update PS AzureRM -> Az (#19913)
Browse files Browse the repository at this point in the history
* Update PS AzureRM -> Az
- Restore AzureRM for AzureCloudPowerShellDeployment
- Changed logic to install Az. modules
- Do not remove AzureRM modules

* Update PS AzureRM -> Az
- Restore AzureRM for AzureCloudPowerShellDeployment
- Changed logic to install Az. modules
- Do not remove AzureRM modules

* Bump versions
  • Loading branch information
DmitriiBobreshev authored May 31, 2024
1 parent 2410102 commit 78b51e7
Show file tree
Hide file tree
Showing 64 changed files with 282 additions and 297 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
$featureFlags = @{
retireAzureRM = [System.Convert]::ToBoolean($env:RETIRE_AZURERM_POWERSHELL_MODULE)
}
$env:RETIRE_AZURERM_POWERSHELL_MODULE = $false

Trace-VstsEnteringInvocation $MyInvocation
Import-VstsLocStrings "$PSScriptRoot\Task.json"
Expand Down Expand Up @@ -36,11 +34,7 @@ try{
if ($EnableAdvancedStorageOptions)
{
$endpoint = Get-VstsEndpoint -Name $ARMConnectedServiceName -Require
if ($featureFlags.retireAzureRM) {
Initialize-AzModule -Endpoint $endpoint
} else {
Initialize-AzureRMModule -Endpoint $endpoint
}
Initialize-AzureRMModule -Endpoint $endpoint
}

# Load all dependent files for execution
Expand Down
33 changes: 4 additions & 29 deletions Tasks/AzureCloudPowerShellDeploymentV1/Utility.ps1
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
$featureFlags = @{
retireAzureRM = [System.Convert]::ToBoolean($env:RETIRE_AZURERM_POWERSHELL_MODULE)
}

function Get-SingleFile($files, $pattern)
function Get-SingleFile($files, $pattern)
{
if ($files -is [system.array])
{
Expand Down Expand Up @@ -61,28 +57,14 @@ function Get-AzureStoragePrimaryKey($storageAccount, [bool]$isArm)
{
if ($isArm)
{
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" }
}
$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"
}

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

if(!$storageAccountKeys)
{
Expand Down Expand Up @@ -206,14 +188,7 @@ function Get-DiagnosticsExtensions($storageAccount, $extensionsPath, $storageAcc
{
try
{
if ($featureFlags.retireAzureRM)
{
$storageContext = New-AzStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
}
else
{
$storageContext = New-AzureStorageContext -StorageAccountName $storageAccountName -StorageAccountKey $storageAccountKey
}
$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
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureCloudPowerShellDeploymentV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV1/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 240,
"Patch": 6
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV1/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 1,
"Minor": 240,
"Patch": 6
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
6 changes: 3 additions & 3 deletions Tasks/AzureFileCopyV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -312,4 +312,4 @@
"AFC_UninstallWinRMCustomScriptExtension": "Uninstall WinRM custom script manually and retry deployment.",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
6 changes: 3 additions & 3 deletions Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -300,4 +300,4 @@
"UnsupportedAuthScheme": "Unsupported authentication scheme '{0}' for endpoint.",
"ServicePrincipalError": "There was an error with the service principal used for the deployment."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
6 changes: 3 additions & 3 deletions Tasks/AzureFileCopyV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -300,4 +300,4 @@
"ServicePrincipalError": "There was an error with the service principal used for the deployment.",
"AzModuleNotFound": "Could not find the modules: 'Az.Accounts'. If the module was recently installed, retry after restarting the Azure Pipelines task agent."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 240,
"Patch": 8
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
6 changes: 3 additions & 3 deletions Tasks/AzureFileCopyV6/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 6,
"Minor": 240,
"Patch": 10
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down Expand Up @@ -287,4 +287,4 @@
"ServicePrincipalError": "There was an error with the service principal used for the deployment.",
"AzModuleNotFound": "Could not find the modules: 'Az.Accounts'. If the module was recently installed, retry after restarting the Azure Pipelines task agent."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/AzureFileCopyV6/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 6,
"Minor": 240,
"Patch": 10
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV2/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV2/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 2,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"demands": [
"azureps"
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV3/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"releaseNotes": "Added support for Fail on standard error and ErrorActionPreference",
"demands": [
Expand Down
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV3/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 3,
"Minor": 240,
"Patch": 4
"Minor": 241,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"demands": [
Expand Down
6 changes: 3 additions & 3 deletions Tasks/AzurePowerShellV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 240,
"Patch": 6
"Minor": 241,
"Patch": 0
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down Expand Up @@ -210,4 +210,4 @@
"JS_Stderr": "PowerShell wrote one or more lines to the standard error stream.",
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 240,
"Patch": 6
"Minor": 241,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
6 changes: 3 additions & 3 deletions Tasks/AzurePowerShellV5/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 240,
"Patch": 6
"Minor": 241,
"Patch": 0
},
"releaseNotes": "Added support for Az Module and cross platform agents.",
"groups": [
Expand Down Expand Up @@ -203,4 +203,4 @@
"ExpiredServicePrincipal": "Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.",
"PS_ExitCode": "PowerShell exited with code '{0}'."
}
}
}
4 changes: 2 additions & 2 deletions Tasks/AzurePowerShellV5/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"author": "Microsoft Corporation",
"version": {
"Major": 5,
"Minor": 240,
"Patch": 6
"Minor": 241,
"Patch": 0
},
"releaseNotes": "ms-resource:loc.releaseNotes",
"groups": [
Expand Down
Loading

0 comments on commit 78b51e7

Please sign in to comment.