As you can see in the script below, I’m simply referencing the “localhost” machine (the machine the script is running on) and just ensuring that the File-Services feature is present. It’s a pretty basic script. I’ve gone ahead and saved the script as FileServerConfig.ps1 on my workstation.
- Configuration FileServerConfig
- Import-DscResource -Module 'PSDesiredStateConfiguration'
- Node "localhost"
- WindowsFeature 'FileServices'
- Ensure = 'Present'
- Name = 'File-Services'
Create an Azure Automation Account
With my configuration script created, I can now go in and start settings thing up.
Before making use of Azure Automation DSC, I first need to provision an Azure Automation account from within my Azure portal.
To create the account, I have to login to my Azure portal and perform the following steps:
- Click green+ New icon in the left pane
- Select Monitoring and Management, and then click Automation in the Monitoring and Management
- In the Add Automation Account pane, enter a name for the new automation account.
- Select my Azure subscription from the dropdown menu.
- Check Create New under Resource Group and enter a name for the new group.
- I could also just add my automation account to an existing Resource Group if I wanted to as well.
- Select a location from the dropdown menu.
- Ensure Create Azure Run-As Account is set to Yes.
- Click Create to deploy my new automation account.
After a few minutes, my Azure Automation Account will be created. If I browse to “Automation Accounts” in the left pane of my portal, I can confirm that my account has been created.
Add a DSC Configuration to Azure Automation
Now that my Azure Automation account has been provisioned, I can add the FileServerConfig.ps1 DSC configuration script to Azure be performing the following steps:
- In the DSC Configurations pane, click Add a Configuration.
- In the Import pane, click the folder icon to browse for a configuration file
- Select FileServerConfig.ps1 and click OK.
- Wait for status to change to Published, and then click on the filename in the DSC Configurations pane and click Compile in Configuration pane.
Again, I’ll need to wait a few minutes for DSC script to be compiled into a MOF file.