Azure recipes

See also: all the recipes and the intro

# docs about Azure VMs

# Azure PowerShell tools

# How to upload a VHD to Azure

# How to acess HTTP PowerShell in Azure
# Script to install the Azure root cert on machines that will be connecting to
# Azure VMs by HTTPS

# How to set up a domain in Azure
Creating an Azure Virtual Network Complete with Domain Controller, Active Directory and SharePoint # Azure key vault intro (kind of crappy)
Securing Azure Web Job Secrets with Azure Key Vault # Example of exporting X509 certs to Azure key vault # Azure ARM storage management & blobs # Azure blob shared access tokens # Azure ARM creating a VM from customer's image: # upload a VHD to the ARM storage account, either through Powershell or through Azure Storage Explorer and run # Azure CRP VM image creation # Azure CRP templates syntax # VM Agent # Azure VM extensions/plugins
Introducing the Azure PowerShell DSC (Desired State Configuration) extension
Custom Script extension for ARM VMs in Azure
# Azure storage # connect to the Azure account, once Add-AzureAccount # configuring the Azure session, for uploading files Get-AzurePublishSettingsFile # do once, downloads the file, may need to change the date on the file name in the next command $sub = Import-AzurePublishSettingsFile "c:\tmp\My Subscription-9-24-2015-credentials.publishsettings" # for Azure ARM Login-AzureRmAccount # upload a VHD Add-AzureVhd -Destination "" -LocalFilePath C:\vm\myimage.vhd # register the VHD as a custom VM image Add-AzureVMImage -ImageName "rtm_74" -MediaLocation "" -OS Windows # create a VM from script New-AzureQuickVM -Windows -ImageName "rtm_74" -Name sbn74 -ServiceName sbn74 -AdminUsername me -CustomDataFile "c:\tmp\bcd.txt" -EnableWinRMHttp -Password "password" -Location "Central US" # Settings for PowerShell login with HTTPS, the tool is downloaded from C:\work\AzureNano\CertManagement\InstallWinRMCertAzureVM.ps1 -Sub "My Subscription" -Ser sbn74 -Name sbn74 enter-pssession -ConnectionUri -Credential "me" # Azure VM extensions # get the list of available extensions # (but doesn't include for example DSC) Get-AzureServiceAvailableExtension # Azure DSC extension
Introducing the Azure PowerShell DSC (Desired State Configuration) extension
# config file C:\tmp\IISInstall.ps1 configuration IISInstall {     node (“localhost”)     {         WindowsFeature IIS         {             Ensure = “Present”             Name = “Web-Server”         }     } } # config file C:\tmp\IISInstall.ps1 # a new VM with the extension Publish-AzureVMDscConfiguration -ConfigurationPath C:\tmp\IISInstall.ps1 Get-AzureStorageBlob -Container windows-powershell-dsc $vm = New-AzureVMConfig -Name “example-1” -InstanceSize Small -ImageName “” $vm = Add-AzureProvisioningConfig -VM $vm -Windows -AdminUsername “admin_account” -Password “password” $vm = Set-AzureVMDSCExtension -VM $vm -ConfigurationArchive “” -ConfigurationName “IISInstall” New-AzureVM -VM $vm -Location “West US” -ServiceName “example-1-svc” -WaitForBoot # adding/changing an extension to a VM $vm = Get-AzureVM -Name “example-1” -ServiceName “example-1-svc” $vm = Set-AzureVMDSCExtension -VM $vm -ConfigurationArchive “” -ConfigurationName “FourthCoffee” $vm | Update-AzureVM # configuring the CustomExtension in my test VM Set-AzureStorageBlobContent -File C:\tmp\runme.ps1 -Container windows-powershell-dsc Get-AzureStorageBlob -Container windows-powershell-dsc # list the blobs $vm = Get-AzureVM -Name "myvm" -ServiceName "myvm" $vm = Set-AzureVMCustomScriptExtension -VM $vm -ContainerName "windows-powershell-dsc" -FileName "runme.ps1" -Run "runme.ps1" -Argument "myarg3 myarg4 >c:\custom.log" $vm | Update-AzureVM Get-AzureVMCustomScriptExtension -vm $vm # configuring the CustomExtension in my test VM in ARM New-NanoServerAzureVM -Location westus -vmname myn75 -AdminUsername me -AdminPassword (ConvertTo-SecureString -Force -AsPlainText "password") -ResourceGroupName mykv2 -VaultName myvault $sac = New-AzureRmStorageAccount -ResourceGroupName mykv2 -name myscript -SkuName Standard_LRS -Location westus $sac = Get-AzureRmStorageAccount -ResourceGroupName mykv2 -name myscript $mycont = New-AzureStorageContainer -Name myscriptc -Context $sac.Context $mycont = Get-AzureStorageContainer -Name myscriptc -Context $sac.Context Set-AzureStorageBlobContent -File C:\tmp\runme.ps1 -Container myscriptc -Context $sac.Context Get-AzureStorageBlob -Container myscriptc -Context $sac.Context $uri = New-AzureStorageBlobSASToken -Container myscriptc -Blob runme.ps1 -Permission r -ExpiryTime ((Get-Date).AddDays(1.0)) -Context $sac.Context -FullUri # wget $uri # $PrivateConfiguration = @{ #     storageAccountName="$ScriptBlobAccount"; #     storageAccountKey="$ScriptBlobKey"; # } $PrivateConfiguration = @{     # commandToExecute can go here, fileUris can't } $PublicConfiguration = @{     fileUris=@(,[string]$uri);     commandToExecute="powershell.exe -ExecutionPolicy Unrestricted -File runme.ps1 poiuyt 444 >c:\runme.log"; } Set-AzureRmVMExtension -ResourceGroupName mykv2 -VMName myn75 -Location westus -Name CustomScript1 -Publisher Microsoft.Compute -ExtensionType CustomScriptExtension -TypeHandlerVersion 1.8 -Settings $PublicConfiguration -ProtectedSettings $PrivateConfiguration -Verbose -Debug



Comments (0)

Skip to main content