You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/automation/automation-dsc-compile.md
+44-71Lines changed: 44 additions & 71 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,32 +25,29 @@ determine when to use which method based on the characteristics of each:
25
25
26
26
For compilation details, see [Desired State Configuration extension with Azure Resource Manager templates](https://docs.microsoft.com/azure/virtual-machines/extensions/dsc-template#details).
27
27
28
-
## Compiling a DSC Configuration in Azure State Configuration
28
+
## Compiling a DSC configuration in Azure State Configuration
29
29
30
30
### Portal
31
31
32
32
1. From your Automation account, click **State configuration (DSC)**.
33
33
1. Click on the **Configurations** tab, then click on the configuration name to compile.
34
34
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.
37
37
38
38
### Azure PowerShell
39
39
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.
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
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.
@@ -135,23 +132,20 @@ configuration. This enables you to apply multiple configurations to a single res
135
132
to learn more about composite resources.
136
133
137
134
> [!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.
139
136
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).
143
138
144
139
### Manage ConfigurationData when compiling configurations in Azure Automation
145
140
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
147
142
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.
149
144
150
145
> [!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.
152
147
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/)
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.
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
234
217
that appears in the DSC configuration and uses credentials.
235
218
236
219
The following example shows a DSC configuration that uses an Automation credential asset.
> 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.
283
265
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
298
267
299
268
The process to compile DSC configurations in Windows PowerShell is included in the PowerShell DSC documentation
300
269
[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.
303
277
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).
306
279
307
280
### Import a node configuration in the Azure portal
308
281
309
282
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.
312
285
313
286

314
287
@@ -318,15 +291,15 @@ in to the Azure State Configuration service.
318
291
### Import a node configuration with Azure PowerShell
319
292
320
293
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.
- 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).
330
303
- 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).
331
304
- For PowerShell cmdlet reference, see [Azure Automation State Configuration cmdlets](/powershell/module/az.automation).
332
305
- For pricing information, see [Azure Automation State Configuration pricing](https://azure.microsoft.com/pricing/details/automation/).
0 commit comments