Getting Started with Azure PowerShell (Classic)

Thanks to opsgility (original post).

For the new AzureRM (resource manager model) please check the official: Get started with Azure PowerShell cmdlets.

Download the Azure PowerShell Cmdlets

Windows install that you can also found at Microsoft Azure Downloads

Configure your Azure Subscription with the Azure PowerShell Cmdlets.

The simplest way to access your Azure subscription from PowerShell is to use the Add-AzureAccount cmdlet.

Add-AzureAccount

After executing the cmdlet a dialog will appear to prompt you to login with your Microsoft or Organization account. After you login, you will have access for 12 hours before you have to login again.

Enumerating and selecting a subscription

You can use the PowerShell cmdlets to enumerate and view your current subscription settings.
Here are some of the more handy ones to know about:

# Enumerates all configured subscriptions on your local machine.
Get-AzureSubscription

# Returns details only on the specified subscription
Get-AzureSubscription -SubscriptionName "mysubscription"

# Select the subscription to use
Select-AzureSubscription -SubscriptionName "mysubscription"

# Sets the mysub subscription to be the default if one is not selected.
Set-AzureSubscription -DefaultSubscription "mysub"

CONFIGURING STORAGE WITH THE CURRENTSTORAGEACCOUNT PARAMETER

When using the WA Cmdlets with Virtual Machines (IaaS) or Cloud Services (PaaS) you will need to specify the CurrentStorageAccount for your subscription. This is basically the storage account that will be used for creating VHDs or uploading .cspkg files. For virtual machines this storage account has to be in the same datacenter that you plan on creating virtual machines in.

Set-AzureSubscription -SubscriptionName "mysub" -CurrentStorageAccount "mystorageaccount"

To discover if you have a storage account or create a new storage account from PowerShell:

# Discover whether you have a storage account already
Get-AzureStorageAccount 

# Creates a new storage account in the West Europe data center
New-AzureStorageAcount -StorageAccountName "mystorageaccountname" -Location "West Europe"

Which of course begs the question – how do I know which data centers are available?

The following cmdlet will give you that information:

Get-AzureLocation

This is everything you need to configure the Azure PowerShell cmdlets for your subscription!

Performance best practices for SQL Server in Azure Virtual Machines (link to resources)

How to create striped disk on azure (AKA Raid 0)

Disk Striping use multiple disks and stripe them together to get a combined higher IOPS and Throughput limit. Note that the combined limit per VM should be higher than the combined limits of attached premium disks.

You can check the maximum number of disks you can add to a virtual machine from here: Sizes for Windows virtual machines in Azure

1. Create “new disk” from powershell:

clear

# RM stands for resource manager, and is the new way of managing things in Azure

# you need to login the first time using this command
# Login-AzureRmAccount

$vm = Get-AzureRmVM -ResourceGroupName "md-test-stripe" -Name "md-test-stripe"

# adds 16 disks
for($i=1; $i -le 16; $i++) {
    $name = "md-test-stripe-disk{0:00}" -f $i
    $lun = $i - 1
    $vhdUri = "https://mdteststripedisks447.blob.core.windows.net/vhds/md-test-stripe-disk{0:00}.vhd" -f $i

    Write-Host "Add-AzureRmVMDataDisk -VM $vm -Name $name -DiskSizeInGB 16 -Lun $lun -Caching None -VhdUri $vhdUri -CreateOption Empty"

    $vm = Add-AzureRmVMDataDisk -VM $vm -Name $name -DiskSizeInGB 16 -Lun $lun -Caching None -VhdUri $vhdUri -CreateOption Empty
}

$vm.DataDiskNames

# uncomment when you are ready, this updates the VM on azure!
# Update-AzureRmVM -ResourceGroupName "md-test-stripe" -VM $vm

2. Create “new storage pool” from server manager with all the new disks you added

3. Create “new virtual disk” from powershell:

New-VirtualDisk -FriendlyName "sql-stripe" -StoragePoolFriendlyName "sql-stripe" -Interleave 65536 -NumberOfColumns 16 -ProvisioningType Fixed -ResiliencySettingName "Simple" -UseMaximumSize

4. Create “new volume” from server manager formatting in NTFS with allocation unit size set to 64KB

Developing against Service Bus for Windows 1.1

roysvork

Wouldn’t it be great if we could work on applications that leverage Microsoft Service Bus locally without having to connect to and potentially pay for Microsoft Azure?

Not everyone knows this, but there’s a local counterpart to Microsoft Azure Service Bus in the form of Service Bus for Windows. Those that do know about it know that it doesn’t have a great development story and can be a pain in the arse to set up.

In this post we’ll take the sting out of the process and show you how you can get your local environment set up so you and the rest of your team can develop against Service Bus without using any Microsoft Azure services.

You’ll need an instance of SQL server to which you have admin rights to use Service Bus for Windows.

IMPORTANT: If you have any other service running that use the default AMQP ports 5671, & 5672 then the configuration…

View original post 1,331 more words

Azure Public IP Addresses

If you like me you’re interested to know the ip ranges that windows azure uses to connect to the internet 🙂 this is the right post 😉

Do not assume that traffic originating from these IP address ranges is trustworthy.

You can download Windows Azure Datacenter IP Ranges xml from the download center.

Here’s the list updated on 12th June 2014

<?xml version="1.0" encoding="utf-8"?>
<AzurePublicIpAddresses xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Region Name="europewest">
    <IpRange Subnet="157.55.9.112/28" />
    <IpRange Subnet="157.55.10.0/26" />
    <IpRange Subnet="65.52.128.0/19" />
    <IpRange Subnet="94.245.97.0/24" />
    <IpRange Subnet="137.116.192.0/19" />
    <IpRange Subnet="157.55.8.64/26" />
    <IpRange Subnet="157.55.8.128/27" />
    <IpRange Subnet="157.55.8.160/28" />
    <IpRange Subnet="168.63.0.0/19" />
    <IpRange Subnet="168.63.96.0/19" />
    <IpRange Subnet="193.149.80.0/22" />
    <IpRange Subnet="213.199.128.0/21" />
    <IpRange Subnet="213.199.136.0/22" />
    <IpRange Subnet="213.199.180.32/28" />
    <IpRange Subnet="213.199.180.96/27" />
    <IpRange Subnet="213.199.180.192/26" />
    <IpRange Subnet="213.199.183.0/24" />
    <IpRange Subnet="23.97.128.0/17" />
    <IpRange Subnet="23.100.0.0/20" />
    <IpRange Subnet="104.40.128.0/19" />
    <IpRange Subnet="137.117.128.0/17" />
    <IpRange Subnet="168.61.56.0/21" />
    <IpRange Subnet="191.233.64.0/18" />
    <IpRange Subnet="191.237.232.0/27" />
    <IpRange Subnet="191.237.232.64/26" />
    <IpRange Subnet="191.237.233.0/24" />
    <IpRange Subnet="191.237.234.0/23" />
    <IpRange Subnet="193.149.84.0/22" />
  </Region>
  <Region Name="useast">
    <IpRange Subnet="23.96.0.0/18" />
    <IpRange Subnet="23.96.64.0/28" />
    <IpRange Subnet="23.96.64.64/26" />
    <IpRange Subnet="23.96.64.128/27" />
    <IpRange Subnet="23.96.64.160/28" />
    <IpRange Subnet="23.96.80.0/20" />
    <IpRange Subnet="23.96.96.0/19" />
    <IpRange Subnet="23.100.16.0/20" />
    <IpRange Subnet="137.116.112.0/20" />
    <IpRange Subnet="137.117.32.0/19" />
    <IpRange Subnet="137.117.64.0/18" />
    <IpRange Subnet="137.135.64.0/18" />
    <IpRange Subnet="157.56.176.0/21" />
    <IpRange Subnet="168.61.32.0/20" />
    <IpRange Subnet="168.61.48.0/21" />
    <IpRange Subnet="168.62.32.0/19" />
    <IpRange Subnet="168.62.160.0/19" />
    <IpRange Subnet="138.91.96.0/25" />
    <IpRange Subnet="138.91.96.128/26" />
    <IpRange Subnet="138.91.96.192/28" />
    <IpRange Subnet="138.91.112.0/20" />
    <IpRange Subnet="191.234.32.0/19" />
    <IpRange Subnet="191.236.0.0/19" />
    <IpRange Subnet="191.238.0.0/25" />
    <IpRange Subnet="191.238.0.128/26" />
    <IpRange Subnet="191.238.0.192/27" />
    <IpRange Subnet="191.238.1.0/24" />
    <IpRange Subnet="191.238.2.0/23" />
    <IpRange Subnet="191.238.4.0/24" />
    <IpRange Subnet="191.238.8.0/21" />
    <IpRange Subnet="191.238.16.0/20" />
    <IpRange Subnet="191.238.32.0/19" />
  </Region>
  <Region Name="uswest">
    <IpRange Subnet="23.100.32.0/20" />
    <IpRange Subnet="137.116.184.0/21" />
    <IpRange Subnet="137.117.0.0/19" />
    <IpRange Subnet="137.117.208.128/28" />
    <IpRange Subnet="137.135.0.0/18" />
    <IpRange Subnet="138.91.64.0/19" />
    <IpRange Subnet="157.56.160.0/21" />
    <IpRange Subnet="168.61.0.0/19" />
    <IpRange Subnet="168.61.64.0/20" />
    <IpRange Subnet="168.62.0.0/19" />
    <IpRange Subnet="168.62.192.0/19" />
    <IpRange Subnet="168.63.88.0/24" />
    <IpRange Subnet="23.99.64.0/19" />
    <IpRange Subnet="138.91.128.0/24" />
    <IpRange Subnet="138.91.129.0/26" />
    <IpRange Subnet="138.91.129.64/28" />
    <IpRange Subnet="138.91.136.0/21" />
    <IpRange Subnet="138.91.144.0/20" />
    <IpRange Subnet="138.91.160.0/19" />
    <IpRange Subnet="138.91.192.0/21" />
    <IpRange Subnet="138.91.224.0/19" />
    <IpRange Subnet="191.238.70.0/23" />
    <IpRange Subnet="23.99.0.0/19" />
    <IpRange Subnet="23.99.32.0/25" />
    <IpRange Subnet="23.99.32.128/28" />
    <IpRange Subnet="23.99.33.0/28" />
    <IpRange Subnet="23.99.34.0/25" />
    <IpRange Subnet="23.99.34.128/26" />
    <IpRange Subnet="23.99.34.192/27" />
    <IpRange Subnet="23.99.35.0/24" />
    <IpRange Subnet="23.99.36.0/24" />
    <IpRange Subnet="23.99.37.0/26" />
    <IpRange Subnet="23.99.37.80/28" />
    <IpRange Subnet="23.99.38.0/24" />
    <IpRange Subnet="23.99.40.0/24" />
    <IpRange Subnet="23.99.48.0/20" />
    <IpRange Subnet="65.52.112.0/20" />
    <IpRange Subnet="104.40.0.0/19" />
    <IpRange Subnet="168.63.89.0/25" />
    <IpRange Subnet="168.63.89.128/26" />
    <IpRange Subnet="191.236.64.0/18" />
    <IpRange Subnet="191.239.0.0/18" />
  </Region>
  <Region Name="usnorth">
    <IpRange Subnet="23.100.72.0/21" />
    <IpRange Subnet="65.52.0.0/19" />
    <IpRange Subnet="65.52.192.0/19" />
    <IpRange Subnet="65.52.48.0/20" />
    <IpRange Subnet="209.240.220.0/23" />
    <IpRange Subnet="65.52.106.16/28" />
    <IpRange Subnet="65.52.106.32/27" />
    <IpRange Subnet="65.52.106.64/26" />
    <IpRange Subnet="65.52.106.128/25" />
    <IpRange Subnet="65.52.107.0/28" />
    <IpRange Subnet="65.52.232.0/21" />
    <IpRange Subnet="65.52.240.0/21" />
    <IpRange Subnet="157.55.24.0/21" />
    <IpRange Subnet="157.55.60.224/27" />
    <IpRange Subnet="157.55.73.32/28" />
    <IpRange Subnet="157.55.136.0/21" />
    <IpRange Subnet="157.55.151.0/28" />
    <IpRange Subnet="157.55.160.0/20" />
    <IpRange Subnet="157.55.208.0/20" />
    <IpRange Subnet="157.55.252.0/22" />
    <IpRange Subnet="157.56.8.0/21" />
    <IpRange Subnet="157.56.24.160/27" />
    <IpRange Subnet="157.56.24.192/28" />
    <IpRange Subnet="157.56.28.0/22" />
    <IpRange Subnet="168.62.96.0/19" />
    <IpRange Subnet="168.62.224.0/20" />
    <IpRange Subnet="168.62.240.0/21" />
    <IpRange Subnet="168.62.248.0/22" />
    <IpRange Subnet="207.46.192.0/20" />
    <IpRange Subnet="23.96.128.0/17" />
    <IpRange Subnet="23.98.48.0/25" />
    <IpRange Subnet="23.98.48.128/26" />
    <IpRange Subnet="23.98.48.192/27" />
    <IpRange Subnet="23.98.48.224/28" />
    <IpRange Subnet="23.98.49.0/24" />
    <IpRange Subnet="23.98.50.0/23" />
    <IpRange Subnet="23.98.52.0/23" />
    <IpRange Subnet="23.98.54.0/24" />
    <IpRange Subnet="23.98.55.0/26" />
    <IpRange Subnet="191.233.128.0/20" />
    <IpRange Subnet="191.236.128.0/18" />
  </Region>
  <Region Name="europenorth">
    <IpRange Subnet="65.52.64.0/20" />
    <IpRange Subnet="65.52.224.0/21" />
    <IpRange Subnet="65.52.248.0/21" />
    <IpRange Subnet="94.245.88.0/21" />
    <IpRange Subnet="94.245.104.0/21" />
    <IpRange Subnet="94.245.112.0/20" />
    <IpRange Subnet="137.116.224.0/19" />
    <IpRange Subnet="157.55.3.0/24" />
    <IpRange Subnet="157.55.230.160/27" />
    <IpRange Subnet="168.61.80.0/20" />
    <IpRange Subnet="168.61.96.0/19" />
    <IpRange Subnet="168.63.32.0/19" />
    <IpRange Subnet="168.63.64.0/20" />
    <IpRange Subnet="168.63.80.0/21" />
    <IpRange Subnet="168.63.92.0/22" />
    <IpRange Subnet="193.149.88.0/21" />
    <IpRange Subnet="23.100.48.0/20" />
    <IpRange Subnet="23.102.0.0/18" />
    <IpRange Subnet="137.135.128.0/17" />
    <IpRange Subnet="138.91.48.0/20" />
    <IpRange Subnet="191.235.128.0/18" />
    <IpRange Subnet="191.235.192.0/24" />
    <IpRange Subnet="191.235.193.0/27" />
    <IpRange Subnet="191.235.193.64/27" />
    <IpRange Subnet="191.235.193.96/28" />
    <IpRange Subnet="191.235.194.0/23" />
    <IpRange Subnet="191.235.208.0/20" />
    <IpRange Subnet="191.235.255.0/26" />
    <IpRange Subnet="191.235.255.64/27" />
    <IpRange Subnet="191.235.255.128/25" />
    <IpRange Subnet="191.237.192.0/23" />
    <IpRange Subnet="191.237.194.0/24" />
    <IpRange Subnet="191.237.208.0/20" />
    <IpRange Subnet="191.238.96.0/19" />
    <IpRange Subnet="191.239.208.0/20" />
  </Region>
  <Region Name="asiaeast">
    <IpRange Subnet="23.98.32.0/21" />
    <IpRange Subnet="23.98.40.0/22" />
    <IpRange Subnet="23.100.88.0/21" />
    <IpRange Subnet="65.52.160.0/19" />
    <IpRange Subnet="111.221.64.0/22" />
    <IpRange Subnet="111.221.69.0/25" />
    <IpRange Subnet="134.170.192.0/21" />
    <IpRange Subnet="137.116.160.0/20" />
    <IpRange Subnet="168.63.128.0/19" />
    <IpRange Subnet="168.63.192.0/19" />
    <IpRange Subnet="207.46.67.160/27" />
    <IpRange Subnet="207.46.67.192/27" />
    <IpRange Subnet="207.46.72.0/26" />
    <IpRange Subnet="207.46.77.224/28" />
    <IpRange Subnet="207.46.87.0/24" />
    <IpRange Subnet="207.46.89.16/28" />
    <IpRange Subnet="207.46.95.32/27" />
    <IpRange Subnet="207.46.128.0/19" />
    <IpRange Subnet="23.97.64.0/20" />
    <IpRange Subnet="23.97.80.0/28" />
    <IpRange Subnet="23.99.96.0/19" />
    <IpRange Subnet="191.234.2.16/28" />
    <IpRange Subnet="191.234.2.32/27" />
    <IpRange Subnet="191.234.2.64/26" />
    <IpRange Subnet="191.234.2.128/26" />
    <IpRange Subnet="191.234.3.0/24" />
    <IpRange Subnet="191.234.16.0/20" />
  </Region>
  <Region Name="asiasoutheast">
    <IpRange Subnet="23.97.48.0/20" />
    <IpRange Subnet="23.100.112.0/21" />
    <IpRange Subnet="111.221.16.0/21" />
    <IpRange Subnet="111.221.80.0/20" />
    <IpRange Subnet="111.221.96.0/20" />
    <IpRange Subnet="137.116.128.0/19" />
    <IpRange Subnet="138.91.32.0/20" />
    <IpRange Subnet="168.63.160.0/19" />
    <IpRange Subnet="168.63.224.0/19" />
    <IpRange Subnet="207.46.48.0/20" />
    <IpRange Subnet="23.98.64.0/20" />
    <IpRange Subnet="168.63.90.0/27" />
    <IpRange Subnet="168.63.90.32/28" />
    <IpRange Subnet="168.63.90.64/27" />
    <IpRange Subnet="191.238.64.0/25" />
    <IpRange Subnet="191.238.64.128/27" />
    <IpRange Subnet="191.238.64.160/28" />
    <IpRange Subnet="207.46.224.0/20" />
  </Region>
  <Region Name="ussouth">
    <IpRange Subnet="65.52.32.0/21" />
    <IpRange Subnet="65.54.48.0/22" />
    <IpRange Subnet="65.54.52.0/26" />
    <IpRange Subnet="65.54.52.64/27" />
    <IpRange Subnet="65.54.52.128/25" />
    <IpRange Subnet="65.54.53.0/24" />
    <IpRange Subnet="65.54.54.0/23" />
    <IpRange Subnet="65.55.64.0/20" />
    <IpRange Subnet="65.55.80.0/21" />
    <IpRange Subnet="65.55.88.0/22" />
    <IpRange Subnet="65.55.92.0/23" />
    <IpRange Subnet="65.55.94.0/24" />
    <IpRange Subnet="65.55.95.0/26" />
    <IpRange Subnet="65.55.95.64/27" />
    <IpRange Subnet="65.55.95.128/25" />
    <IpRange Subnet="70.37.48.0/20" />
    <IpRange Subnet="70.37.64.0/19" />
    <IpRange Subnet="70.37.96.0/20" />
    <IpRange Subnet="70.37.112.0/22" />
    <IpRange Subnet="70.37.116.0/23" />
    <IpRange Subnet="70.37.118.0/24" />
    <IpRange Subnet="70.37.119.64/26" />
    <IpRange Subnet="70.37.119.128/26" />
    <IpRange Subnet="70.37.119.208/28" />
    <IpRange Subnet="70.37.119.224/27" />
    <IpRange Subnet="70.37.120.0/22" />
    <IpRange Subnet="70.37.124.0/23" />
    <IpRange Subnet="70.37.126.0/26" />
    <IpRange Subnet="70.37.126.64/27" />
    <IpRange Subnet="70.37.126.128/25" />
    <IpRange Subnet="70.37.127.0/26" />
    <IpRange Subnet="70.37.127.240/28" />
    <IpRange Subnet="70.37.160.0/21" />
    <IpRange Subnet="157.55.80.0/21" />
    <IpRange Subnet="157.55.103.32/27" />
    <IpRange Subnet="157.55.153.224/28" />
    <IpRange Subnet="157.55.176.0/20" />
    <IpRange Subnet="157.55.192.0/21" />
    <IpRange Subnet="157.55.200.0/22" />
    <IpRange Subnet="168.62.128.0/19" />
    <IpRange Subnet="23.98.128.0/19" />
    <IpRange Subnet="23.98.160.0/23" />
    <IpRange Subnet="23.98.162.0/28" />
    <IpRange Subnet="23.98.162.32/28" />
    <IpRange Subnet="23.98.162.64/26" />
    <IpRange Subnet="23.98.162.128/28" />
    <IpRange Subnet="23.98.162.176/28" />
    <IpRange Subnet="23.98.164.0/23" />
    <IpRange Subnet="23.98.167.0/24" />
    <IpRange Subnet="23.98.169.0/24" />
    <IpRange Subnet="23.98.176.0/20" />
    <IpRange Subnet="23.98.192.0/25" />
    <IpRange Subnet="23.98.208.0/20" />
    <IpRange Subnet="23.98.255.0/27" />
    <IpRange Subnet="23.98.255.32/28" />
    <IpRange Subnet="23.98.255.64/26" />
    <IpRange Subnet="23.100.120.0/21" />
    <IpRange Subnet="23.102.128.0/18" />
    <IpRange Subnet="191.238.128.0/19" />
    <IpRange Subnet="191.238.160.0/20" />
    <IpRange Subnet="191.238.224.0/19" />
  </Region>
  <Region Name="japanwest">
    <IpRange Subnet="23.98.56.0/26" />
    <IpRange Subnet="23.98.56.64/27" />
    <IpRange Subnet="23.98.56.96/28" />
    <IpRange Subnet="23.98.56.128/26" />
    <IpRange Subnet="23.100.104.0/21" />
    <IpRange Subnet="138.91.16.0/20" />
    <IpRange Subnet="191.233.32.0/19" />
    <IpRange Subnet="191.237.236.0/24" />
    <IpRange Subnet="191.238.80.0/20" />
  </Region>
  <Region Name="japaneast">
    <IpRange Subnet="23.98.57.0/25" />
    <IpRange Subnet="23.98.57.128/27" />
    <IpRange Subnet="23.100.96.0/21" />
    <IpRange Subnet="138.91.0.0/20" />
    <IpRange Subnet="191.234.138.0/24" />
    <IpRange Subnet="23.102.64.0/20" />
    <IpRange Subnet="191.237.240.0/28" />
    <IpRange Subnet="191.237.241.0/24" />
  </Region>
  <Region Name="brazilsouth">
    <IpRange Subnet="23.97.96.0/20" />
    <IpRange Subnet="23.97.112.0/25" />
    <IpRange Subnet="23.97.112.128/28" />
    <IpRange Subnet="191.237.248.0/21" />
  </Region>
</AzurePublicIpAddresses>

How to use a Local Storage Resource

The Windows Azure Managed Library provides classes for accessing the local storage resource from within code that is running in a role instance.

You will just need to retrieve the full path of a named local storage, and then you can store any file you want. To retrieve the full path, you simple need this line of code:

RoleEnvironment.GetLocalResource("MainLocalStorage").RootPath

Create Local Storage on Cloud Services to store temporary files

On a cloud service, you can create a small local storage where you can save temporary files, yes I said temporary, because a local storage would not be guaranteed to be durable, for durable storage in Azure you should consider Azure SQL Database or Azure Storage (blob and tables). This reserved space could be useful to store custom error log files (nlog, log4net, …), for those files that are dynamically created by the application and you would like to cache it somewhere, and also for structured data files like database(sql ce, sqlite, …), but remember, just for volatile data.

You can create a local storage manually configuring the Service Definition configuration file, or through the visual studio user interface:

Open the Properties of the Web Role under the Cloud Service Project, go to Local Storage section, and click on “Add Local Storage”, name the storage, give a size, and save.

Create Local Storage

For more information about Local Storage Resources visit http://msdn.microsoft.com/en-us/library/windowsazure/ee758708.aspx