Skip to content

Instantly share code, notes, and snippets.

@ajith-k
ajith-k / GetRegionalSvcIPRanges.ps1
Last active October 15, 2020 10:52
Get region specific service public IPs
##############################################
## Set your region and the location of the public IP json file
##
$myRegion = "AzureCloud.JapanEast"
$IPListJsonFile = "C:\sandbox\ServiceTags_Public_20201012.json"
## Service List for Azure Backup per NSG tags documented
## NOTE : Any of these services can loadbalance to endpoints from other regions. Will need testing.
$serviceList= ("AzureBackup","Storage","AzureActiveDirectory")
###
## DISCLAIMER : This is a sample and is provided as is with no warranties express or implied.
##
## Instructions :-
## 1.Launch cloudshell and set the subscription context using
## Set-AzContext -SubscriptionID <yoursubscription>
## 2.Click "Raw" on this github gist and copy everything after the line "##StartCopy"
## 3.Execute this script in the cloud shell to register the routine.
## 4.Execute it as Get-NonCoolBlobs -RGName MyResourceGroup -Name MyStorageAccount
###
@ajith-k
ajith-k / BlobPC.ps1
Last active July 30, 2019 08:42
Producer Consumer approach to blob manipulation for performance.
#####
## Save out file as say BlobPC.ps1
## Edit for necessary changes
## Execute in a sub process by calling powershell.exe .\BlobPC.ps1
##
## NOTE: If you do not use a sub process the class will stay in the application domain and cause failures on rerun
##
$StorageAccountName = "mystorageaccount"
$StorageAccountRG = "myresourcegroupname"
###
## DISCLAIMER : This is a sample and is provided as is with no warranties express or implied.
##
## Instructions :-
## 1.Launch cloudshell and set the subscription context using
## Set-AzContext -SubscriptionID <yoursubscription>
## 2.Click "Raw" on this github gist and copy everything after the line "##StartCopy"
## 3.Execute this script in the cloud shell to register the routine.
## 4.Execute it as Get-CoolBlobs -RGName MyResourceGroup -Name MyStorageAccount
###
###
## DISCLAIMER : This is a sample and is provided as is with no warranties express or implied.
##
###
[CmdletBinding(DefaultParametersetName="SharedKey")]
param(
[Parameter(Mandatory=$true, HelpMessage="Storage Account Name")]
[String] $storage_account_name,
@ajith-k
ajith-k / TestBlobUsingSAS.ps1
Created April 30, 2019 15:08
SAS method to create a blob, read and then delete it
## Customer specific data
$storageaccountname = "ajtstsa"
$sastoken = "?sv=2018-03-28&ss=b&srt=sco&sp=rwdlac&se=2019-04-30T22:33:54Z&st=2019-04-29T14:33:54Z&spr=https,http&sig=yXWcUTBsLPp%2B8ab6IRLzgwQJsfsBp3h3yk4WKiD4%2Fig%3D"
$container = "sasaccesstest"
$blobname = "mytestblob.txt"
## Construct required variables"
$containeruri="https://$storageaccountname.blob.core.windows.net/$container$sastoken&restype=container"
$bloburi="https://$storageaccountname.blob.core.windows.net/$container/$blobname$sastoken"
$blobdata = "Test blob data"
@ajith-k
ajith-k / ArchiveOldBlob.ps1
Last active January 29, 2019 04:33
Sets the tier of blobs older than certain number of days to Archive.
###
## DISCLAIMER : This is a sample and is provided as is with no warranties express or implied.
##
###
[CmdletBinding(DefaultParametersetName="SharedKey")]
param(
[Parameter(Mandatory=$true, HelpMessage="Storage Account Name")]
[String] $storage_account_name,
###
## DISCLAIMER : This is a sample and is provided as is with no warranties express or implied.
##
## The RemoveSoftDeletedBlobs switch will cause changes to the storage account. Please ensure you test and
## understand all implications before running this against critical data.
##
###
[CmdletBinding(DefaultParametersetName="SharedKey")]
param(
@ajith-k
ajith-k / GetPremiumStorageQuotaUsage.ps1
Last active October 1, 2019 17:23
Enumerate all blobs in a premium storage account and sum up the provisioned sizes of the page blobs
[CmdletBinding()]
Param (
[Parameter (Mandatory=$true, HelpMessage="Premium Storage Account resource URI")]
[String] $storageResourceId
)
# Enable Verbose logs for debugging
$VerbosePreference = "Continue"
function PrintServiceStats
{
Param(
[Parameter (Mandatory=$True,Position=1)] [string] $storageAccountName,
[Parameter (Mandatory=$True,Position=2)] [string] $accountSASToken,
[Parameter (Mandatory=$True,Position=3)] [string] $service
)
$accountSASParam = $accountSASToken.Replace("?","")
$statsURI = "https://$storageAccountName-secondary.$service.core.windows.net/?restype=service&comp=stats&$accountSASParam"
$resp = Invoke-WebRequest -Method Get -Uri $statsURI