Skip to content

Commit

Permalink
Removing warning of AzureRm module (#12407)
Browse files Browse the repository at this point in the history
* Removing warning of AzureRm mosule

* Adding latest module of Az
  • Loading branch information
20shivangi authored Feb 26, 2020
1 parent 5c985ad commit 2e6f045
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
5 changes: 4 additions & 1 deletion Tasks/AzureFileCopyV4/AzureFileCopy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ Import-Module $PSScriptRoot\ps_modules\VstsAzureHelpers_

$endpoint = Get-VstsEndpoint -Name $connectedServiceName -Require

# Update PSModulePath for hosted agent
. "$PSScriptRoot\Utility.ps1"
CleanUp-PSModulePathForHostedAgent

if (Get-Module Az.Accounts -ListAvailable){
Initialize-AzModule -Endpoint $endpoint
}
Expand All @@ -75,7 +79,6 @@ Import-VstsLocStrings -LiteralPath $PSScriptRoot/Task.json

# Load all dependent files for execution
. "$PSScriptRoot\AzureFileCopyRemoteJob.ps1"
. "$PSScriptRoot\Utility.ps1"

# Enabling detailed logging only when system.debug is true
$enableDetailedLogging = ($env:system_debug -eq "true")
Expand Down
26 changes: 26 additions & 0 deletions Tasks/AzureFileCopyV4/Utility.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1301,4 +1301,30 @@ function Get-InvokeRemoteScriptParameters
protocol = $protocol;
sessionOption = $sessionOption
}
}

function CleanUp-PSModulePathForHostedAgent {
# Clean up PSModulePath for hosted agent
$azureRMModulePath = "C:\Modules\azurerm_2.1.0"
$azureModulePath = "C:\Modules\azure_2.1.0"
$newEnvPSModulePath = $env:PSModulePath

if ($newEnvPSModulePath.split(";") -contains $azureRMModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureRMModulePath }) -join ";"
write-verbose "$azureRMModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureRMModulePath is not present in $newEnvPSModulePath"
}

if ($newEnvPSModulePath.split(";") -contains $azureModulePath) {
$newEnvPSModulePath = (($newEnvPSModulePath).Split(";") | ? { $_ -ne $azureModulePath }) -join ";"
write-verbose "$azureModulePath removed. Restart the prompt for the changes to take effect."
}
else {
write-verbose "$azureModulePath is not present in $newEnvPSModulePath"
}

$azPSModulePath = "C:\Modules\az_3.1.0"
$env:PSModulePath = $azPSModulePath + ";" + $newEnvPSModulePath
}
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 165,
"Minor": 166,
"Patch": 0
},
"preview": true,
Expand Down
2 changes: 1 addition & 1 deletion Tasks/AzureFileCopyV4/task.loc.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"author": "Microsoft Corporation",
"version": {
"Major": 4,
"Minor": 165,
"Minor": 166,
"Patch": 0
},
"preview": true,
Expand Down

0 comments on commit 2e6f045

Please sign in to comment.