Import-AzureRmAutomationDscConfiguration: File name shouldn't be required to match the DSC Configuration name
When you use the Import-AzureRmAutomationDscConfiguration command to import a PowerShell script file into an Azure Automation Account, the file name must match the DSC configuration name. If the DSC Configuration name, and the script file name that contains it, do not match, then you receive the exception below.
This is inconsistent with the Azure Portal experience, where no such naming requirement exists.
Import-AzureRmAutomationDscConfiguration : BadRequest: The configuration name in the script must match the configuration name.
At C:\Users\TrevorSullivan\Documents\Import DSC Configuration.ps1:26 char:1
+ Import-AzureRmAutomationDscConfiguration @DscConfiguration;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Import-AzureRmAutomationDscConfiguration], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.ImportAzureAutomationDscConfiguration
Cheers, Trevor Sullivan Microsoft MVP: PowerShell http://trevorsullivan.net http://twitter.com/pcgeek86
@pcgeek86 This seems like an unnecessary restriction. Adding in the automation team.
@markcowl Thanks Mark! This should be a fairly straightforward fix, and might even result in removing some code, instead of adding code. :)
This is by design. Same as on the runbook side.
@jodoglevy If it's by design, then the inconsistency with the Portal experience should be rectified. What was the reasoning behind the current PowerShell design?
I did not know we allowed this from the portal. Given we do, maybe we should match in the cmdlets, yes. But I would say its a best practice to name your PSWF runbook / DSC Configuration file with the same name as the PSWF runbook / DSC Configuration it contains. Otherwise it will get confusing when you have many PSWF runbooks / DSC Configs in files, as to what each file contains. You shouldn't need to open a runbook / config file up to know which runbooks / config is in the file.
You shouldn't need to open a runbook / config file up to know which runbooks / config is in the file.
That's a nice thought, but probably better for the user to make that decision, or at least be consistent between interfaces and document the requirement in detail. If you support it via the Portal, then why not via automation interfaces?
NOTE: I just ran into this bug again.
In addition to my above reason, script runbooks don’t have a name declaration within the file like workflows / configurations do. The file name is used as the script name. I’d think we’d want to be consistent across all runbook / config types as to where the item name comes from (to be the file name).
Also, referencing a child script runbook from a runbook inline uses the file name (just like scripts locally): .\myrunbook.ps1
Am I losing my mind? :\Windows\system32> Import-AzureRmAutomationDscConfiguration -SourcePath C:\whatever\setup-sql-2016.ps1 mport-AzureRmAutomationDscConfiguration : BadRequest: The configuration name in the script must match the configuration name.
In the file I have "Configuration setup-sql-2016" I've also tried with name without hyphens, so setupsql2016.ps1 and "Configuration setupsql2016"
Okay, so this makes a bit more sense, but still doesn't give me all the answers: "The name can only contain letters,numbers and underscores. The name must start with a letter, and it must end with a letter or number."
setupsql2016 - satisfies all the conditions and today it worked, but 2 days ago, it didn't. huh?
This restriction still seems to be in place. Is there any update on this? It feels a bit strange, that the ps1 name and the configuration name should be the same.
I got this, please remove the restriction - I am confident that I am capable of managing a set of files :)
Just ran into this as well. Are there still plans to remove this restriction?
@jodoglevy Why is this designed this way? I do not recall any documentation stating that this was best practice, nor do I believe it is best practice as Azure really doesn't care about the file names after import.
It seems there are two arbitrary restrictions applied to the powershell module that are not applied to the portal:
- The node configuration name must match the file name
- The node configuration name cannot contain hyphens
Neither of these restrictions are on the portal. Can you PLEASE just remove these restrictions, there's no understandable reason for them to be there!
I'm no longer working on this project, folks. @eamonoreilly can you take a look?
@vrdmr @eamonoreilly Can you take another look at this issue?
I also ran into this issue. Another note through trial and error, it turns out uppercase letters are also not allowed.
Still encountering this with the new Az equivalent: Import-AzAutomationDscConfiguration. My import ONLY succeeded when I matched the -SourcePath value and the configuration name.
`Import-AzAutomationDscConfiguration : {"code":"BadRequest","message":"The configuration name in the script must match the configuration name."} At line:1 char:1
- Import-AzAutomationDscConfiguration -SourcePath "C:\Dev\DSC\powerstig ...
-
+ CategoryInfo : CloseError: (:) [Import-AzAutomationDscConfiguration], ErrorResponseException + FullyQualifiedErrorId : Microsoft.Azure.Commands.Automation.Cmdlet.ImportAzureAutomationDscConfiguration`
Edit: Also worth mentioning this was Azure US Government with a USGov Texas automation account.
Can anybody please take care of this? This issue is now open more than 3 years and should not be so hard to get fixed.
Triaged: Bug filed.
The behavior in the portal is similar - pick a file and the config name is generated from that.