azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Import-AzureRmAutomationDscConfiguration: File name shouldn't be required to match the DSC Configuration name

Open pcgeek86 opened this issue 10 years ago • 26 comments

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 avatar Feb 11 '16 19:02 pcgeek86

@pcgeek86 This seems like an unnecessary restriction. Adding in the automation team.

markcowl avatar Feb 12 '16 21:02 markcowl

@markcowl Thanks Mark! This should be a fairly straightforward fix, and might even result in removing some code, instead of adding code. :)

pcgeek86 avatar Feb 13 '16 19:02 pcgeek86

This is by design. Same as on the runbook side.

JAL9302 avatar Mar 12 '16 00:03 JAL9302

@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?

pcgeek86 avatar Mar 14 '16 02:03 pcgeek86

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.

JAL9302 avatar Mar 14 '16 18:03 JAL9302

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.

pcgeek86 avatar May 02 '16 20:05 pcgeek86

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

JAL9302 avatar May 05 '16 00:05 JAL9302

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?

4c74356b41 avatar Sep 14 '16 14:09 4c74356b41

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.

DdenBraver avatar Mar 24 '17 10:03 DdenBraver

I got this, please remove the restriction - I am confident that I am capable of managing a set of files :)

GoEddie avatar Jun 16 '17 08:06 GoEddie

Just ran into this as well. Are there still plans to remove this restriction?

raandree avatar Jul 31 '17 10:07 raandree

@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.

lfshr avatar Aug 09 '17 06:08 lfshr

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!

AndrewShepherd avatar Aug 10 '17 03:08 AndrewShepherd

I'm no longer working on this project, folks. @eamonoreilly can you take a look?

JAL9302 avatar Aug 10 '17 03:08 JAL9302

@vrdmr @eamonoreilly Can you take another look at this issue?

maddieclayton avatar Mar 10 '18 00:03 maddieclayton

I also ran into this issue. Another note through trial and error, it turns out uppercase letters are also not allowed.

jeffgebhardt avatar Apr 23 '18 23:04 jeffgebhardt

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.

timothytavarez avatar May 27 '19 01:05 timothytavarez

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.

raandree avatar May 27 '19 12:05 raandree

Triaged: Bug filed.

andyw248 avatar Jun 15 '19 18:06 andyw248

The behavior in the portal is similar - pick a file and the config name is generated from that.

andyw248 avatar Oct 15 '19 22:10 andyw248