Skip to content

Instantly share code, notes, and snippets.

View nmackenzie's full-sized avatar

Neil Mackenzie nmackenzie

  • Microsoft
  • San Francisco, CA
View GitHub Profile
@nmackenzie
nmackenzie / LoadBalancedVM.ps1
Created October 25, 2015 19:23
Create a load-balanced pair of Azure VMs
$testName = "lower-case-unique-name"
$resourceGroupName = $testName
$location = "westus"
$domainName = $testName
$subnetName = "Subnet-1"
$publisher = "MicrosoftWindowsServer"
$offer = "WindowsServer"
$sku = "2012-R2-Datacenter"
@nmackenzie
nmackenzie / CreateServicePrincipal.ps1
Created May 31, 2015 01:48
Create an AAD service principal and configure it for AAD authentication for the Azure PowerShell cmdlets
#
# Sign-in as a user in the Owner role
#
Add-AzureAccount
#
# Sign-in to MSOL
#
Connect-MsolService
@nmackenzie
nmackenzie / SingleVM.ps1
Created October 25, 2015 19:09
Create a single VM using Azure PowerShell v1
$testName = "lower-case-unique-name"
$resourceGroupName = $testName
$location = "westus"
$publisher = "MicrosoftWindowsServer"
$offer = "WindowsServer"
$sku = "2012-R2-Datacenter"
$version = "latest"
var query = (
from entity in bookTable.CreateQuery<DynamicTableEntity>()
where entity.Properties["PartitionKey"].StringValue == "hardback"”" &&
entity.Properties["Year"].Int32Value == 1912
select entity);
List<DynamicTableEntity> books = query.ToList();
EntityResolver<Writer> resolver = (pk, rk, ts, props, etag) =>
{
Writer writer = new Writer() {
Information = String.Format("{0} wrote {1} in {2}",
props["Author"].StringValue, props["Name"].StringValue,
props["Year"].Int32Value)
};
return writer;
};
var query =
(from book in bookTable.CreateQuery<DynamicTableEntity>()
where book.PartitionKey == "hardback"
select book).Resolve( (pk,rk,ts,props,etag) =>
String.Format("{0} wrote {1} in {2}",
props["Author"].StringValue, props["Name"].StringValue, props["Year"].Int32Value));
public TableQuerySegment<TElement>
ExecuteSegmented(TableContinuationToken continuationToken,
TableRequestOptions requestOptions = null,
OperationContext operationContext = null);
public delegate T EntityResolver<T>(string partitionKey, string rowKey,
DateTimeOffset timestamp,
IDictionary<string, EntityProperty> properties, string etag);
TableQuery<BookEntity> query =
(from book in bookTable.CreateQuery<BookEntity>()
where book.PartitionKey == "hardback"
select book).AsTableQuery<BookEntity>();
TableContinuationToken continuationToken = null;
do {
var queryResult = query.ExecuteSegmented(continuationToken);
foreach (BookEntity entity in queryResult) {
var query = (from book in bookTable.CreateQuery<BookEntity>()
where book.PartitionKey == "hardback"
select book).Take(10);