Skip to content

Instantly share code, notes, and snippets.

View astaykov's full-sized avatar

Anton Staykov astaykov

  • Microsoft (former Microsoft Azure MVP)
  • Berlin, Germany
  • X @astaykov
View GitHub Profile
@astaykov
astaykov / gist:5038664
Created February 26, 2013 14:09
Command line to use within Windows Azure Startup task (or any environemnt) to set 32bit Application Pool defaults, so that your Web App will run under 32bits. This must be run elevated.
%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.enable32BitAppOnWin64:true
@astaykov
astaykov / gist:5134934
Last active December 14, 2015 19:09
Dealing with Context in WSFederation and ACS
[AllowAnonymous]
[ValidateInput(false)]
public class AcsResponseController : Controller
{
public ActionResult Index()
{
if (ControllerContext.HttpContext.Request.Form["wresult"] != null)
{
// This is a response from the ACS - you can further inspect the message if you will
SignInResponseMessage message =
@astaykov
astaykov / DeployAzureVMWithDns
Created December 9, 2013 08:14
PowerShell to deploy DNS server VM to Windows Azure by specifying local DNS settings. Important are lines 6 and 11!
Add-AzureAccount
Set-AzureSubscription "[Your Subscription Name]" -CurrentStorageAccountName "[StorageAccount_for_VHDs]"
$adminPassword = "Super_Secret_Password!"
$images = Get-AzureVMImage | where {$_.Label -match "Windows Server 2012 R2"}
$vmImage = $images[2]
$dnsServerLocal = New-AzureDns –Name "NameResolver" –IPAddress "127.0.0.1"
New-AzureVMConfig -Name "NameResolver" -InstanceSize Large -ImageName $vmImage.ImageName ` |
Add-AzureProvisioningConfig –Windows –Password $adminPassword -AdminUsername "astaykov" ` |
Set-AzureSubnet "NSNet" ` |
@astaykov
astaykov / azureADsetup.ps1
Created March 27, 2014 23:19
Azure VM - AD/DC with DNS Server and a Client
# first authenticate using your Azure Active Directory credentials
Add-AzureAccount
# then list all the subscriptions to get the name
Get-AzureSubscription
# now set the subscription context as well as default storage account that
# will be used for rest of the operations
# note, the account has to be created in the same Affinity Group as the Virtual Network !!
Set-AzureSubscription "[YOUR Subscription Name]" -CurrentStorageAccountName "[azurestorageaccount]"
@astaykov
astaykov / non-interactive-azure-manage
Created August 13, 2014 15:57
Non-interactive Azrue PowerShell management
# first save encrypted password to a file that can later be used
read-host -assecurestring | convertfrom-securestring | out-file d:\tmp\securestring.txt
# then use the saved password
$password = cat d:\tmp\securestring.txt | convertto-securestring
# currently (August, the 13nd, 2014) only organizational accounts are supported (also with custom domain).
# Microsoft Accounts (Live ID) are not supported
$username = "user@tenant.onmicrosoft.com" # or user@yourdomain.com if 'yourdomain.com' is registered with AAD
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$password
Add-AzureAccount -credential $mycred
@astaykov
astaykov / azure-powershell-bulk-add-endpoints
Created August 14, 2014 07:01
Azure IaaS PowerShell bulk add endpoints
Add-AzureAccount
Select-AzureSubscription -SubscriptionName "Your_Subscription_Name"
$vm = Get-AzureVM -ServiceName "CloudServiceName" -Name "VM_Name"
for ($i=6100; $i -le 6120; $i++)
{
$EndpointName = "FtpEndpoint_"
$EndpointName += $i
Add-AzureEndpoint -Name $EndpointName -Protocol "tcp" -PublicPort $i -LocalPort $i -VM $vm
}
$vm | Update-AzureVM
cmd.exe /c $env:windir\system32\inetsrv\appcmd.exe list apppool "apppoolname" /text:ProcessModel.Password
@astaykov
astaykov / AzureCloudServiceAntiMalwareProtection.ps1
Created September 15, 2014 12:53
Azure Cloud Service Antimalware Protection extension
Add-AzureAccount
# use Select-AzureSubscription in case your account has more than one
Select-AzureSubscription -SubscriptionName 'PUT HERE YOUR SUBSCRIPTION'
[System.Xml.XmlDocument] $XmlConfig = New-Object System.Xml.XmlDocument
# load the Antimalware extension configuration from external XML file
# The content of the XML needs to be:
# <AntimalwareConfig><AntimalwareEnabled>true</AntimalwareEnabled></AntimalwareConfig>
# ref.: http://msdn.microsoft.com/en-US/library/azure/dn771718
$XmlConfig.load('D:\tmp\AntiMalware.config')
Set-AzureServiceAntimalwareExtension -ServiceName "PUT HERE THE CLOUD SERVICE NAME" -AntimalwareConfiguration $XmlConfig
netsh http add urlacl url=https://+:4444/ user=[Existing user on the system]
netsh http add sslcert ipport=0.0.0.0:4444 certhash=[thumbprint of SSL cert] appid={[GUID - a freely chosen GUID]}
@astaykov
astaykov / Azure_Update_ServiceConfig
Created September 29, 2014 06:46
Update service configuration of Cloud Service
# Add the Azure Account first - this will create a login promppt
Add-AzureAccount
# when you have more then one subscription - you have explicitly select the one
# which holds your cloud service you want to update
Select-AzureSubscription "<Subscription name with spaces goes here>"
# then Update the configuration for the cloud service
Set-AzureDeployment -Config -ServiceName "<cloud_service_name_goes_here>" `
-Configuration "D:/tmp/cloud/ServiceConfiguration.Cloud.cscfg" `
-Slot "Production"