Skip to content

Instantly share code, notes, and snippets.

View sandrinodimattia's full-sized avatar
🏠
Working from home

Sandrino Di Mattia sandrinodimattia

🏠
Working from home
View GitHub Profile
var ctx = new Microsoft.WindowsAzure.Storage.Table.DataServices.TableServiceContext(table.ServiceClient);
var query = ctx.CreateQuery<BlogPostTableServiceEntity>("ChronoTableStorageSample")
.Where(QueryDateReverseChronologicalComparisons.After,
DateTime.Parse("2012-12-10 00:00:00"));
foreach (var blogPost in query)
{
Console.WriteLine("{0:yyyy-MM-dd}: {1}", blogPost.PublishedOn, blogPost.Title);
}
public static class BlogReader
{
public static IEnumerable<Model.BlogPost> Read()
{
using (var rdr = System.Xml.XmlReader.Create("http://blogs.msdn.com/b/windowsazure/rss.aspx"))
{
foreach (var item in SyndicationFeed.Load(rdr).Items)
{
yield return new Model.BlogPost()
{
@sandrinodimattia
sandrinodimattia / gist:4215259
Created December 5, 2012 12:49
Adding and removing RDP endpoint (by Michael Washam)
# Remove RDP endpoints from VMs in cloud service
Get-AzureVM -ServiceName myservice | Remove-AzureEndpoint -Name RemoteDesktop
| Update-AzureVM
# Add RDP endpoints to all VMs in cloud service
Get-AzureVM -ServiceName myservice | Add-AzureEndpoint -Name RemoteDesktop -LocalPort 3389 -Protocol tcp
| Update-AzureVM
@sandrinodimattia
sandrinodimattia / gist:4214953
Created December 5, 2012 11:47
Rename-Administrator.ps1
$user = Get-WMIObject Win32_UserAccount -Filter "Name='Administrator'"
$username = -join ([Char[]]'abcdefghijklmnopqrstuvwxyz._-~´`àéèç' | Get-Random -count 15)
$user.Rename($username)
@sandrinodimattia
sandrinodimattia / Ex1.cs
Created November 23, 2012 11:43
UpdateObject
// Example 1: Simply updating an entity does not work if not calling UpdateObject
string tableName = "testupdate";
string partition = "Customers";
client.GetTableReference(tableName)
.CreateIfNotExists();
var rowKey = DateTime.Now.ToString("HHmmss");
// User A creates customer.
@sandrinodimattia
sandrinodimattia / gist:4128693
Created November 22, 2012 00:30
Call Import-AzureEndpointsFromCSV.ps1
Import-AzurePublishSettingsFile 'C:\...'
Select-AzureSubscription -SubscriptionName ...
# Import normal endpoints.
$vm = Get-AzureVM MyVirtualMachine
.\Import-AzureEndpointsFromCSV.ps1 $vm Normal-Endpoints.csv NoLB
# Import load-balanced endpoints.
$vm = Get-AzureVM MyLoadBalancedCloudSvc
.\Import-AzureEndpointsFromCSV.ps1 $vm[0] LB-Endpoints.csv LoadBalanced
@sandrinodimattia
sandrinodimattia / Import-AzureEndpointsFromCSV.ps1
Created November 22, 2012 00:10
Script which imports endpoints
# Arguments.
param
(
[Microsoft.WindowsAzure.Management.ServiceManagement.Model.PersistentVMRoleContext]$vm = $(throw "'vm' is required."),
[string]$csvFile = $(throw "'csvFile' is required."),
[string]$parameterSet = $(throw "'parameterSet' is required.")
)
Get-ChildItem "${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows Azure\PowerShell\Azure\*.dll" | ForEach-Object {[Reflection.Assembly]::LoadFile($_) | out-null }
# Add endpoints without loadbalancer.
@sandrinodimattia
sandrinodimattia / gist:4115136
Created November 20, 2012 00:26
Call Install-FTPServer.cmd
Install-FTPServer.cmd "passiveftp" "C:\FtpServer" 2500 10000 10125 168.63.28.123
@sandrinodimattia
sandrinodimattia / gist:4115110
Created November 20, 2012 00:21
IIS8 - Install FTP Server
REM Variables.
SETLOCAL EnableDelayedExpansion
SET FtpSiteName=%1%
SET FtpDirectory=%2%
SET PublicPort=%3%
SET DynamicPortFirst=%4%
SET DynamicPortLast=%5%
SET DynamicPortRange=%DynamicPortFirst%-%DynamicPortLast%
SET PublicIP=%6%
@sandrinodimattia
sandrinodimattia / gist:4114985
Created November 19, 2012 23:55
Call Add-AzureFtpEndpoints.ps1
Import-AzurePublishSettingsFile 'C:\...'
Select-AzureSubscription -SubscriptionName ...
$vm = Get-AzureVM passiveftp
Add-AzureFtpEndpoints.ps1 $vm 2500 10000 10125