Here is a quick script to use to upload Modules to Azure Automation.
$cred = Get-Credential
Add-AzureAccount -Credential $cred
Select-AzureSubscription -SubscriptionId <SubscriptionID>
$ResourceGroup = Get-AzureResourceGroup -Name "IaaSAutomation"
$MyAutomationAccount = $ResourceGroup | Get-AzureAutomationAccount -Name "IaaSAutomation"
$MyAutomationAccount | New-AzureAutomationModule -name "xWebAdministration" -ContentLink "https://github.com/PowerShell/xWebAdministration/archive/126.96.36.199-PSGallery.zip"
$MyAutomationAccount | New-AzureAutomationModule -name "xPhp" -ContentLink "https://github.com/PowerShell/xPhp/archive/188.8.131.52-PSGallery.zip"
$MyAutomationAccount | New-AzureAutomationModule -name "xWordPress" -ContentLink "https://github.com/PowerShell/xWordPress/archive/184.108.40.206-PSGallery.zip"
$MyAutomationAccount | New-AzureAutomationModule -name "xMySQL" -ContentLink "https://github.com/PowerShell/xMySql/archive/220.127.116.11-PSGallery.zip"
It has been awhile since I have blogged, and it is time to change that and share what I have been working on recently.
In this blog series I am going to walk you through how to deploy VMs in Azure using your own customized image using Azure Automation. To get started if you don’t already have an azure subscription you can sign up for one here. We are going to cover a lot of different technologies/topics in this series so I plan to use this Intro blog post as an index for the series and a mast list of resources. As I find new resources for Azure I plan to update this post.
We will be using the Azure Resource Manager API in all of the blog post unless stated otherwise. (links to post will be updated as I post them)
- Connecting to Azure with Azure PowerShell Module
- ARM: Create Storage account with Azure PowerShell Module
- ARM: Upload resources to Azure Storage
- ARM: Create Azure Automation Account
- ARM: IaaS Automation Setup Script
- ARM: Uploading ARM PowerShell Module to Azure Automation
- ARM: New-ARMDeployment Runbook
- ARM: Json Templates
- ARM Templates – Visual Studio overview
- ARM Template – Standard Windows VM from Azure gallery
- ARM Template – Domain Join
- ARM Template – Custom image
- ARM Template – Multiple VMs in Single deployment
- ARM: Uploading ARM Templates to Azure Storage
- ARM: Preparing VM Image to upload
- ARM: Prepare RHEL Image for Azure
- ARM: Upload VHD Images to Azure Storage
- ARM: Deploy-VM Runbook
- ARM: Invoke Runbook via Webhooks
- ARM: Invoke Runbook from Service Manager
- ARM: Link VM to Azure Automation DSC Configuration
While you’re waiting for the next blog post check out my Azure DSC blogs
- Enable Azure Automation DSC Preview
- Register Servers to Azure Automation DSC
- Azure Automation DSC – Uploading Configurations
- Azure Automation DSC – Linking a Node to Node Configuration
In this post we are going to apply the DSC Configuration we uploaded in the last blog post to a Server Node.
Lets check the status of the compilation job
We can see that the status now says complete.
Check the status of the Node we want to apply the configuration too
you will notice that the NodeConfigurationName property is null, this means that there is not a configuration applied to the node.
Lets double check what Configurations we have loaded in Azure Automation DSC that we can apply to this node.
by running the cmdlet $MyAutomationAccount | Get-AzureAutomationDscNodeConfiguration we see that we have two configurations, we are going to use the webserver.IIS and apply it to the DemoDSC Node by running:
$WebNode = $MyAutomationAccount | Set-AzureAutomationDscNode -NodeConfigurationName “webserver.IIS” -id “024b8929-f98b-11e4-80bb-000d3a9096e9”
the ID parameter on the Set-AzureAutomationDscNode command is the ID of the Node as you can see in the above image the demodsc node now has a configuration and the ID property matches the ID I entered in the cmdlet.
below you can see that initially we had the base 14 Windows Features installed, I forced the configuration to apply by running the Update-DSCConfiguration -wait -verbose cmdlet, if i would not have run this command the configuration would have applied the next time the DSC client checked in to Azure Automation DSC. After the DSC Configuration was applied 27 windows Features were installed.
In the past few blog post I have shown you how to get started with Azure Automation DSC, in the first blog post I coved how to Enable Azure Automation Preview and in the second how to Register Servers to Azure Automation DSC. In this blog post I am going to go over how we can upload a DSC configuration to Azure Automation DSC.
First we will need a Configuration, there are a few public repositories the most popular two are on Github and Powershellgallery. for my example we are going to use the configuration below.
Name = 'web-server'
Ensure = 'Present'
save the above configuration as webserver.ps1
Upload Configuration to Azure Automation DSC
$myConfig = $MyAutomationAccount | Import-AzureAutomationDscConfiguration -SourcePath 'C:\DSCConfigs\webserver.ps1' -Description "Test WebServer Config" -Published -force
$myConfig = Get-AzureAutomationDSCConfiguration -ResourceGroupName "mms-eus" -AutomationAccountName "MSDNAutomation"
Start Compilation Job
$myCompileJob = $myConfig | Start-AzureAutomationDscCompilationJob
Check Status of Compilation Job
$myCompileJob | Get-AzureAutomationDscCompilationJob
In the next blog post I will show you how to link the configuration to a Node.
In the previous blog post I showed you how to enable Azure Automation DSC Preview, now lets take a look at how we can register existing on premise servers to Azure Automation DSC.
First we need to export meta configurations from Azure.
Switch-AzureMode -Name AzureResourceManager
Select-AzureSubscription -SubscriptionName "<Subscription Name>"
$ResourceGroup = Get-AzureResourceGroup -Name "<Resource Group Name>"
$MyAutomationAccount = $ResourceGroup | Get-AzureAutomationAccount -Name "<AccountName>"
$MyAutomationAccount | Get-AzureAutomationDscOnboardingMetaconfig -OutputFolder C:\temp\ -Force ##Make sure the direcory exist already
Now we can move the DscMetaConfigs directory that was downloaded in the previous script, to a network share or a local machine.
This single command needs to be run on the local server that you want to register to Azure Automation DSC to set the local DSC Configuration to use Azure Automation as the Pull Server.
I installed the latest PowerShell v5 update on my test machine to get this next command to work, you can download it here.
Set-DscLocalConfigurationManager -Path "<Path>\DscMetaConfigs" -Verbose
as you can see below I now have one node registered with Azure Automation DSC
If you are registering a new Azure VM with Azure Automation DSC the process can be done at build time of the VM.