Closed deathly809 closed 5 years ago
@cormacpayne , @markcowl , any update on this bug yet? Wanted to get a sense of what the issue is, and if you guys had an ETA for the fix. We have a couple of our customers try to use this functionality.
@knithinc @deathly809 Yes, the issue is that, if there is an existing context, the token cache from the imported context does not overwrite it - this is because we cannot combine two token caches.
If the TokenCache is completely new, then the problem does not occur, however, we are not checking for an existing but empty token cache. The right fix is to replace the token cache in all cases, but we have deprioritized this because using Context AutoSave should make this unnecessary.
@markcowl We also have reports saying passing the Context to a Job is also broken.. root cause is likely the same?
Agree that enabling context auto save will make this pattern unnecessary and we have suggested the same.
$context = Get-AzureRMContext;
$vms = get-azurermvm | where {$_.Tags.pool -eq $vmPool} | where ResourceGroupName -eq $rg | sort Name
$script = {
Param( $rg, $vm, $context )
$vmname = $vm.Name
$vm.NetworkProfile.NetworkInterfaces[0].id -match "Interfaces/(.*)"
$nicname = $matches[1]
$osdiskname = $vm.StorageProfile.OSDisk.Name
$datadisknames = $vm.StorageProfile.DataDisks.Name
Remove-AzureRmVm -Name $vmName -ResourceGroupName $rg -AzureRmContext $context -force -verbose
Remove-AzureRmNetworkInterface -Name $nicname -ResourceGroupName $rg -AzureRmContext $context -force -verbose
Remove-AzureRmDisk -Name $osdiskname -ResourceGroupName $rg -AzureRmContext $context -force -verbose
$datadisknames | %{ Remove-AzureRmDisk -Name $_ -ResourceGroupName $rg -AzureRmContext $context -force -verbose }
}
$jobs = @()
$vms | %{
$job = Start-Job -Name $_.Name $script -ArgumentList $rg, $_, $context
Write-Output "($_.Name) being removed in background job $($job.Name) ID $($job.Id)"
$jobs += @($job)
}
No this is separate, and my guess is that you have one or more parameter passing issues in this case.
Closing this as a duplicate of #7456
The issue is fixed in Az module, Keeping this open for AzureRm.Profile module fix as this exists in AzureRm
The fix is part of AzureRM.Profile 5.8.3
Description
When using Save-AzureRMContext in one PowerShell window and Import-AzureRMContext in another window does not allow me to call commands.
Script/Steps for Reproduction
Module Version
Environment Data
Debug Output
Save
Load