Azure / Azure/azure-powershell

Import-AzureRmAutomationDscConfiguration: Needs to check for existence of file before making API calls

Open
#1,804 4 comments 0 reactions 2 assignees Claimed by @GaneshMSAzure View on GitHub
act-codegen-extensibility-squad Automation automation-dsc Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
2d 17h
Merged PRs (30d)
51

Description

# Issue

The `Import-AzureRmAutomationDscConfiguration` command doesn't check for the existence of the file path specified in the `-SourcePath` parameter. If the file doesn't exist, the command still attempts to make the API call to Microsoft Azure, which returns the exception below.

```
Import-AzureRmAutomationDscConfiguration : BadRequest: {"Message":"Invalid argument specified. Argument script cannot be null."}
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
```
# Expected Result

The `Import-AzureRmAutomationDscConfiguration` command should check for the existence of the file in `-SourcePath` before it attempts to make any API calls against Azure. If the file does not exist, a more useful error message should be thrown, instead of the generic one coming back from the ARM REST API.

Cheers,
**Trevor Sullivan**
Microsoft MVP: PowerShell
http://trevorsullivan.net
http://twitter.com/pcgeek86

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.