Skip to content

Commit 6aaf67d

Browse files
authored
Merge pull request #104759 from BethWilke/task107
Fixing task 1675322
2 parents a55b72c + 833d0da commit 6aaf67d

File tree

1 file changed

+44
-71
lines changed

1 file changed

+44
-71
lines changed

articles/automation/automation-dsc-compile.md

Lines changed: 44 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,29 @@ determine when to use which method based on the characteristics of each:
2525

2626
For compilation details, see [Desired State Configuration extension with Azure Resource Manager templates](https://docs.microsoft.com/azure/virtual-machines/extensions/dsc-template#details).
2727

28-
## Compiling a DSC Configuration in Azure State Configuration
28+
## Compiling a DSC configuration in Azure State Configuration
2929

3030
### Portal
3131

3232
1. From your Automation account, click **State configuration (DSC)**.
3333
1. Click on the **Configurations** tab, then click on the configuration name to compile.
3434
1. Click **Compile**.
35-
1. If the configuration has no parameters, you are prompted to confirm whether you want to compile it. If the configuration has parameters, the **Compile Configuration** blade opens so that you can provide parameter values.
36-
1. The **Compilation Job** page is opened so that you can track the compilation job's status, and the node configurations (MOF configuration documents) it caused to be placed on the Azure Automation State Configuration Pull Server.
35+
1. If the configuration has no parameters, you are prompted to confirm that you want to compile it. If the configuration has parameters, the **Compile Configuration** blade opens so that you can provide parameter values.
36+
1. The Compilation Job page is opened so that you can track the compilation job's status. You can also use this page to track the node configurations (MOF configuration documents) that the job places on the Azure Automation State Configuration pull server.
3737

3838
### Azure PowerShell
3939

40-
You can use [`Start-AzAutomationDscCompilationJob`](/powershell/module/az.automation/start-azautomationdsccompilationjob)
41-
to start compiling with Windows PowerShell. The following sample code starts compilation of a DSC configuration called **SampleConfig**.
40+
You can use [Start-AzAutomationDscCompilationJob](/powershell/module/az.automation/start-azautomationdsccompilationjob)
41+
to start compiling with Windows PowerShell. The following sample code begins compilation of a DSC configuration called SampleConfig.
4242

4343
```powershell
4444
Start-AzAutomationDscCompilationJob -ResourceGroupName 'MyResourceGroup' -AutomationAccountName 'MyAutomationAccount' -ConfigurationName 'SampleConfig'
4545
```
4646

47-
`Start-AzAutomationDscCompilationJob` returns a compilation job object that you can use to
48-
track its status. You can then use this compilation job object with
49-
[`Get-AzAutomationDscCompilationJob`](/powershell/module/az.automation/get-azautomationdsccompilationjob)
50-
to determine the status of the compilation job, and
51-
[`Get-AzAutomationDscCompilationJobOutput`](/powershell/module/az.automation/get-azautomationdscconfiguration)
52-
to view its streams (output). The following sample code starts compilation of the **SampleConfig**
53-
configuration, waits until it has completed, and then displays its streams.
47+
**Start-AzAutomationDscCompilationJob** returns a compilation job object that you can use to track its status. You can then use this compilation job object with [Get-AzAutomationDscCompilationJob](/powershell/module/az.automation/get-azautomationdsccompilationjob)
48+
to determine the status of the compilation job, and with
49+
[Get-AzAutomationDscCompilationJobOutput](/powershell/module/az.automation/get-azautomationdscconfiguration)
50+
to view its streams (output). The following sample code starts compilation of the SampleConfig configuration, waits until it has completed, and then displays its streams.
5451

5552
```powershell
5653
$CompilationJob = Start-AzAutomationDscCompilationJob -ResourceGroupName 'MyResourceGroup' -AutomationAccountName 'MyAutomationAccount' -ConfigurationName 'SampleConfig'
@@ -135,23 +132,20 @@ configuration. This enables you to apply multiple configurations to a single res
135132
to learn more about composite resources.
136133

137134
> [!NOTE]
138-
> For configurations containing **Composite Resources** to compile correctly, you must first ensure that any DSC Resources that the composite relies on are first imported in to Azure Automation.
135+
> For configurations containing composite resources to compile correctly, you must first ensure that any DSC resources that the composite relies on are imported into Azure Automation.
139136
140-
Adding a DSC **Composite Resource** is no different than adding any PowerShell module to Azure Automation.
141-
The step by step instruction for this process is documented in the article
142-
[Manage Modules in Azure Automation](/azure/automation/shared-resources/modules).
137+
Adding a DSC composite resource is no different from adding a PowerShell module to Azure Automation. The process is documented in [Manage Modules in Azure Automation](/azure/automation/shared-resources/modules).
143138

144139
### Manage ConfigurationData when compiling configurations in Azure Automation
145140

146-
**ConfigurationData** allows you to separate structural configuration from any environment-specific
141+
The **ConfigurationData** feature allows you to separate structural configuration from any environment-specific
147142
configuration while using PowerShell DSC. See [Separating "What" from "Where" in PowerShell DSC](https://blogs.msdn.com/b/powershell/archive/2014/01/09/continuous-deployment-using-dsc-with-minimal-change.aspx)
148-
to learn more about **ConfigurationData**.
143+
to learn more about ConfigurationData.
149144

150145
> [!NOTE]
151-
> You can use **ConfigurationData** when compiling in Azure Automation State Configuration using Azure PowerShell but not in the Azure portal.
146+
> You can use ConfigurationData when compiling in Azure Automation State Configuration using Azure PowerShell, but not in the Azure portal.
152147
153-
The following example DSC configuration uses **ConfigurationData** via the **$ConfigurationData**
154-
and **$AllNodes** keywords. You also need the [**xWebAdministration** module](https://www.powershellgallery.com/packages/xWebAdministration/)
148+
The following example DSC configuration uses ConfigurationData via the $ConfigurationData and $AllNodes keywords. You also need the [xWebAdministration module](https://www.powershellgallery.com/packages/xWebAdministration/)
155149
for this example:
156150

157151
```powershell
@@ -173,9 +167,8 @@ Configuration ConfigurationDataSample
173167
}
174168
```
175169

176-
You can compile the preceding DSC configuration with Windows PowerShell. The following script adds two
177-
node configurations to the Azure Automation State Configuration Pull Service:
178-
**ConfigurationDataSample.MyVM1** and **ConfigurationDataSample.MyVM3**:
170+
You can compile the preceding DSC configuration with Windows PowerShell. The following script adds two node configurations to the Azure Automation State Configuration pull service:
171+
ConfigurationDataSample.MyVM1 and ConfigurationDataSample.MyVM3.
179172

180173
```powershell
181174
$ConfigData = @{
@@ -204,33 +197,23 @@ Start-AzAutomationDscCompilationJob -ResourceGroupName 'MyResourceGroup' -Automa
204197

205198
### Work with assets in Azure Automation during compilation
206199

207-
Asset references are the same in Azure Automation State Configuration and runbooks. For more information, see the
200+
Asset references are the same in both Azure Automation State Configuration and runbooks. For more information, see the
208201
following:
209202

210203
- [Certificates](automation-certificates.md)
211204
- [Connections](automation-connections.md)
212205
- [Credentials](automation-credentials.md)
213206
- [Variables](automation-variables.md)
214207

215-
#### Credential Assets
208+
#### Credential assets
216209

217210
DSC configurations in Azure Automation can reference Automation credential assets using the
218-
`Get-AutomationPSCredential` cmdlet. If a configuration has a parameter that has a **PSCredential**
219-
type, then you can use the `Get-AutomationPSCredential` cmdlet by passing the string name
220-
of an Azure Automation credential asset to the cmdlet to retrieve the credential. You can then use
221-
that object for the parameter requiring the **PSCredential** object. Behind the scenes, the Azure
222-
Automation credential asset with that name is retrieved and passed to the configuration. The
223-
example below shows this in action.
224-
225-
Keeping credentials secure in node configurations (MOF configuration documents) requires encrypting
226-
the credentials in the node configuration MOF file. However, currently you must tell PowerShell DSC
227-
it is okay for credentials to be outputted in plain text during node configuration MOF generation,
228-
because PowerShell DSC doesn’t know that Azure Automation will be encrypting the entire MOF file
229-
after its generation via a compilation job.
230-
231-
You can tell PowerShell DSC that it is okay for credentials to be outputted in plain text in the
232-
generated node configuration MOFs using Configuration Data. You should
233-
pass `PSDscAllowPlainTextPassword = $true` via **ConfigurationData** for each node block’s name
211+
**Get-AutomationPSCredential** cmdlet. If a configuration has a parameter that has a PSCredential type, then you can use **Get-AutomationPSCredential** by passing in the string name of an Azure Automation credential asset to retrieve the credential. You can then use that object for the parameter requiring the PSCredential object. Behind the scenes, the Azure
212+
Automation credential asset with that name is retrieved and passed to the configuration. The example below shows this operation in action.
213+
214+
Keeping credentials secure in a node configuration requires encrypting the credentials in the node configuration MOF file. You must inform PowerShell DSC specifically that it has permission to output credentials in plain text during node configuration MOF generation. PowerShell DSC doesn’t know that Azure Automation encrypts the entire MOF file after its generation via a compilation job.
215+
216+
To give PowerShell DSC permission to output credentials in plain text in the generated node configuration MOFs using configuration data, pass `PSDscAllowPlainTextPassword = $true`. You can pass this information via ConfigurationData for each node block name
234217
that appears in the DSC configuration and uses credentials.
235218

236219
The following example shows a DSC configuration that uses an Automation credential asset.
@@ -253,9 +236,10 @@ Configuration CredentialSample
253236
}
254237
```
255238

256-
You can compile the preceding DSC configuration with PowerShell. The following PowerShell adds two
257-
node configurations to the Azure Automation State Configuration Pull Server:
258-
**CredentialSample.MyVM1** and **CredentialSample.MyVM2**.
239+
You can compile the preceding DSC configuration with PowerShell.
240+
241+
The following PowerShell adds two node configurations to the Azure Automation State Configuration pull server:
242+
CredentialSample.MyVM1 and CredentialSample.MyVM2.
259243

260244
```powershell
261245
$ConfigData = @{
@@ -276,39 +260,28 @@ $ConfigData = @{
276260
Start-AzAutomationDscCompilationJob -ResourceGroupName 'MyResourceGroup' -AutomationAccountName 'MyAutomationAccount' -ConfigurationName 'CredentialSample' -ConfigurationData $ConfigData
277261
```
278262

279-
> [!NOTE]
280-
> When compilation is complete you may receive an error stating: **The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management' snap-in was already imported.** This warning can safely be ignored.
281-
282-
## Compiling configurations in Windows PowerShell
263+
>[!NOTE]
264+
>When compilation is complete, you might receive an error stating: **The 'Microsoft.PowerShell.Management' module was not imported because the 'Microsoft.PowerShell.Management' snap-in was already imported.** You can safely ignore this warning.
283265
284-
You can also import node configurations (MOFs) that have been compiled outside of Azure.
285-
This includes compiling from a developer workstation or in a service such as
286-
[Azure DevOps](https://dev.azure.com).
287-
There are multiple advantages to this approach including performance and reliability.
288-
Compiling in Windows PowerShell also provides the option to sign configuration content.
289-
A signed node configuration is verified locally on a managed node by the DSC agent,
290-
ensuring that the configuration being applied to the node comes from an authorized source.
291-
292-
> [!NOTE]
293-
> A node configuration file must be no larger than 1 MB to allow it to be imported into Azure Automation.
294-
295-
For more information about how to sign node configurations, see [Improvements in WMF 5.1 - How to sign configuration and module](/powershell/scripting/wmf/whats-new/dsc-improvements#dsc-module-and-configuration-signing-validations).
296-
297-
### Compile a configuration in Windows PowerShell
266+
## Compiling a DSC configuration in Windows PowerShell
298267

299268
The process to compile DSC configurations in Windows PowerShell is included in the PowerShell DSC documentation
300269
[Write, Compile, and Apply a Configuration](/powershell/scripting/dsc/configurations/write-compile-apply-configuration#compile-the-configuration).
301-
This can be executed from a developer workstation or within a build service such as
302-
[Azure DevOps](https://dev.azure.com).
270+
You can execute the process from a developer workstation or within a build service, such as [Azure DevOps](https://dev.azure.com).
271+
You can then import the MOFs for the resulting node configurations directly into the Azure State Configuration service.
272+
273+
>[!NOTE]
274+
>A node configuration file must be no larger than 1 MB to allow it to be imported into Azure Automation.
275+
276+
You can also import node configurations (MOFs) that have been compiled outside of Azure. There are multiple advantages to this approach, including performance and reliability.
303277

304-
The MOF file or files produced by compiling the configuration can then be imported directly
305-
in to the Azure State Configuration service.
278+
Compiling in Windows PowerShell provides the option to sign configuration content, with the DSC agent verifying a signed node configuration locally on a managed node. Verification ensures that the configuration being applied to the node comes from an authorized source. For more information about signing node configurations, see [Improvements in WMF 5.1 - How to sign configuration and module](/powershell/scripting/wmf/whats-new/dsc-improvements#dsc-module-and-configuration-signing-validations).
306279

307280
### Import a node configuration in the Azure portal
308281

309282
1. From your Automation account, click **State configuration (DSC)** under **Configuration Management**.
310-
1. In the **State configuration (DSC)** page, click on the **Configurations** tab, then click **+ Add**.
311-
1. In the **Import** page, click the folder icon next to the **Node Configuration File** textbox to browse for a node configuration file (MOF) on your local computer.
283+
1. On the State configuration (DSC) page, click on the **Configurations** tab, then click **+ Add**.
284+
1. On the Import page, click the folder icon next to the **Node Configuration File** textbox to browse for a node configuration file (MOF) on your local computer.
312285

313286
![Browse for local file](./media/automation-dsc-compile/import-browse.png)
314287

@@ -318,15 +291,15 @@ in to the Azure State Configuration service.
318291
### Import a node configuration with Azure PowerShell
319292

320293
You can use the [Import-AzAutomationDscNodeConfiguration](/powershell/module/az.automation/import-azautomationdscnodeconfiguration)
321-
cmdlet to import a node configuration into your automation account.
294+
cmdlet to import a node configuration into your Automation account.
322295

323296
```powershell
324297
Import-AzAutomationDscNodeConfiguration -AutomationAccountName 'MyAutomationAccount' -ResourceGroupName 'MyResourceGroup' -ConfigurationName 'MyNodeConfiguration' -Path 'C:\MyConfigurations\TestVM1.mof'
325298
```
326299

327300
## Next steps
328301

329-
- To get started, see [Getting started with Azure Automation State Configuration](automation-dsc-getting-started.md.
302+
- To get started, see [Getting started with Azure Automation State Configuration](automation-dsc-getting-started.md).
330303
- To learn about compiling DSC configurations so that you can assign them to target nodes, see [Compiling configurations in Azure Automation State Configuration](automation-dsc-compile.md).
331304
- For PowerShell cmdlet reference, see [Azure Automation State Configuration cmdlets](/powershell/module/az.automation).
332305
- For pricing information, see [Azure Automation State Configuration pricing](https://azure.microsoft.com/pricing/details/automation/).

0 commit comments

Comments
 (0)