Using AzureStorageContext inside of powershell workflow
Date : March 29 2020, 07:55 AM
seems to work fine You should be able to put the InlineScript block within the foreach -parallel, that will run all the InlineScripts in parallel: $destinationContext = (New-AzureStorageContext -StorageAccountName $destinationAccountName -StorageAccountKey $destinationAccountKey)
$sourceContext = (New-AzureStorageContext -StorageAccountName $prodAccountName -StorageAccountKey $prodAccountKey)
$allContainers = Get-AzureStorageContainer -Context $sourceContext
$startTime = Get-Date -Format "yyyyMMddhhmmss"
foreach ($container in $allContainers.Name)
{
$allBlobs = (Get-AzureStorageBlob -Container $container -Context $sourceContext).Name
foreach -Parallel ($blob in $allBlobs)
{
InlineScript {
$destinationContext = (New-AzureStorageContext -StorageAccountName $using:destinationAccountName -StorageAccountKey $using:destinationAccountKey)
$sourceContext = (New-AzureStorageContext -StorageAccountName $using:prodAccountName -StorageAccountKey $using:prodAccountKey)
$fileName = $using:startTime + "/" + $using:container + "/" + $using:blob
Write-Information "Copying $fileName"
Start-AzureStorageBlobCopy -SrcBlob $using:blob -DestBlob $fileName -SrcContainer $using:container -Context $sourceContext -DestContext $destinationContext -DestContainer $using:destinationContainer
}
}
}
|
How can I call New-AzureStorageContext using -SasToken instead of -StorageAccountKey
Date : March 29 2020, 07:55 AM
hope this fix your issue I think you've discovered a bug in Storage Client Library. I traced the code from PowerShell to Storage Client Library and here's what I found. PowerShell Cmdlet code tries to create a StorageCredentials object by passing this SAS Token. public StorageCredentials(string sasToken)
{
CommonUtility.AssertNotNullOrEmpty("sasToken", sasToken);
this.SASToken = sasToken;
this.UpdateQueryBuilder();
}
private void UpdateQueryBuilder()
{
SasQueryBuilder newQueryBuilder = new SasQueryBuilder(this.SASToken);
newQueryBuilder.Add(Constants.QueryConstants.ApiVersion, Constants.HeaderConstants.TargetStorageVersion);
this.queryBuilder = newQueryBuilder;
}
|
Mocked class recognized as 'static member' is being called but it is not being recognized in the test as the mock?
Tag : java , By : tangsty
Date : March 29 2020, 07:55 AM
To fix this issue For mocking static classes we need to use PowerMockito. Use the following call to prepare you static class methods for mocking PowerMockito.mockStatic(TRDIUtils.class)
PowerMockito.when(TRDIUtilsstrToInteger(newValueIn)).thenReturn(0);
|
New-AzureStorageContext: Endpoint vs Environment
Date : March 29 2020, 07:55 AM
Hope this helps what are the differences between the Endpoint and Environment parameters?
|
"'New-AzureStorageContext' is not recognized," Yet the Module is Installed
Tag : azure , By : alexandruz
Date : March 29 2020, 07:55 AM
may help you . The command New-AzureStorageContext you used belongs to the AzureRM powershell module, it is different from the new module Az , you have not installed it, that caused the issue. To fix the issue, you could refer to the solutions below. Enable-AzureRmAlias [-Module <string>] [-Scope Process | CurrentUser | LocalMachine]
Disable-AzureRmAlias [-Module <string[]>] [-Scope Process | CurrentUser | LocalMachine]
|