Changes per feedback and code review.
This commit is contained in:
Родитель
5451131d39
Коммит
c2073b9586
|
@ -118,10 +118,14 @@ function Get-ContainerBytes
|
|||
$containerSizeInBytes += $Container.GetPermissions().SharedAccessPolicies.Count * 512
|
||||
|
||||
# Calculate size of all blobs.
|
||||
$blobCount = 0
|
||||
Get-AzureStorageBlob -Context $storageContext -Container $Container.Name |
|
||||
ForEach-Object { $containerSizeInBytes += Get-BlobBytes $_ }
|
||||
ForEach-Object {
|
||||
$containerSizeInBytes += Get-BlobBytes $_
|
||||
$blobCount++
|
||||
}
|
||||
|
||||
return $containerSizeInBytes
|
||||
return @{ "containerSize" = $containerSizeInBytes; "blobCount" = $blobCount }
|
||||
}
|
||||
|
||||
$storageAccount = Get-AzureStorageAccount -StorageAccountName $StorageAccountName -ErrorAction SilentlyContinue
|
||||
|
@ -152,11 +156,12 @@ $sizeInBytes = 0
|
|||
if ($containers.Count -gt 0)
|
||||
{
|
||||
$containers | ForEach-Object {
|
||||
$containerSize = Get-ContainerBytes $_.CloudBlobContainer
|
||||
$sizeInBytes += $containerSize
|
||||
Write-Verbose ("Container '{0}' size is {1:F2}MB." -f $_.CloudBlobContainer.Name, ($containerSize / 1MB))
|
||||
$result = Get-ContainerBytes $_.CloudBlobContainer
|
||||
$sizeInBytes += $result.containerSize
|
||||
Write-Verbose ("Container '{0}' with {1} blobs has a size of {2:F2}MB." -f `
|
||||
$_.CloudBlobContainer.Name, $result.blobCount, ($result.containerSize / 1MB))
|
||||
}
|
||||
Write-Output ("Total size calculated is {0:F2}GB." -f ($sizeInBytes / 1GB))
|
||||
Write-Output ("Total size calculated for {0} containers is {1:F2}GB." -f $containers.Count, ($sizeInBytes / 1GB))
|
||||
|
||||
# Launch default browser to azure calculator for data management.
|
||||
Start-Process -FilePath http://www.windowsazure.com/en-us/pricing/calculator/?scenario=data-management
|
||||
|
|
|
@ -6,17 +6,12 @@
|
|||
Start's an asynchronous copy of VHD's to a different subscription and storage account.
|
||||
.EXAMPLE
|
||||
.\CopyAllVhdBetweenSubscription.ps1
|
||||
-DestSubName "DestinationSubscriptionName" `
|
||||
-DestContainer "DestinationContainerName"
|
||||
-DestStorageAcc "DestinationStorageAccount"
|
||||
-DestStorageKey "DestinationStorageKey"
|
||||
-DestContainerName "DestinationContainerName"
|
||||
-DestStorageAccountName "DestinationStorageAccount"
|
||||
-DestStorageAccountKey "DestinationStorageKey"
|
||||
#>
|
||||
param
|
||||
(
|
||||
# Destination Subscription Name
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]$DestSubscriptionName,
|
||||
|
||||
# Destination Storage Container name
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]$DestContainerName,
|
||||
|
@ -61,7 +56,7 @@ foreach ($azureDisk in Get-AzureDisk)
|
|||
if ($vhdName -ne $null)
|
||||
{
|
||||
# Copy Blob
|
||||
$storageBlobsCopied += Start-CopyAzureStorageBlob -SrcUri $src -DestContainer $DestContainerName `
|
||||
$storageBlobsCopied += Start-AzureStorageBlobCopy -SrcUri $src -DestContainer $DestContainerName `
|
||||
-DestBlob $vhdName –destContext $DestContext
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
Set-AzureSubscription -SubscriptionName "MySubscription" -CurrentStorageAccount "MyStorageAccount"
|
||||
.EXAMPLE
|
||||
.\CopyFilesFromAzureStorageContainer -LocalPath "c:\users\<myUserName>\documents" `
|
||||
-StorageContainer "myuserdocuments" -Recurse -CreateStorageContainer
|
||||
-StorageContainer "myuserdocuments"
|
||||
#>
|
||||
[CmdletBinding(SupportsShouldProcess = $true)]
|
||||
param(
|
||||
|
|
|
@ -71,7 +71,7 @@ workflow UploadFilesInParallel
|
|||
{
|
||||
Set-AzureStorageBlobContent -Container $StorageContainer `
|
||||
-File $file.FullName -Blob $blobFileName `
|
||||
-ConcurrentTaskCount 0 -Force -ErrorAction SilentlyContinue
|
||||
-ConcurrentTaskCount 0 -Force
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
This script will run through a single Azure storage account and delete all blobs in
|
||||
all containers including snapshots.
|
||||
.EXAMPLE
|
||||
.\Remove-BlobsFromAllContainers.ps1 -StorageAccountName "storageaccountname"
|
||||
.\Remove-BlobsFromAllContainers.ps1 -StorageAccountName "storageaccountname" -Force
|
||||
#>
|
||||
|
||||
[CmdletBinding(SupportsShouldProcess = $true)]
|
||||
|
@ -68,7 +68,7 @@ foreach($container in $containers)
|
|||
|
||||
if ($blobs -ne $null)
|
||||
{
|
||||
if ($blobs.Length -gt 0)
|
||||
if ($blobs.Count -gt 0)
|
||||
{
|
||||
if (($Force.IsPresent) -or
|
||||
($PSCmdlet.ShouldContinue(
|
||||
|
|
Загрузка…
Ссылка в новой задаче