Showing posts with label visualstudio. Show all posts
Showing posts with label visualstudio. Show all posts

How to Fix the [ERROR] Get-ChildItem when Deploying an Azure Resource Group in Visual Studio

Lately, I've been having some trouble when deploying from Visual Studio. First, I didn't care since I didn't have time to investigate and also because most of the time using PowerShell or Azure CLI. However, this issue was not usual of Visual Studio, so I decided to see what was the problem and try to fix it.

The Problem


In a solution, I added a simple Azure Resource Group deployment project just like this one.

simpleProject

Then when I try to right-click and do a Deploy...

Deploy

I was having this error message:

 - The following parameter values will be used for this operation:
 - Build started.
 - Project "TestARMProject.deployproj" (StageArtifacts target(s)):
 - Project "TestARMProject.deployproj" (ContentFilesProjectOutputGroup target(s)):
 - Done building project "TestARMProject.deployproj".
 - Done building project "TestARMProject.deployproj".
 - Build succeeded.
 - Launching PowerShell script with the following command:
 - 'D:\Dev\local\TestARMProject\TestARMProject\bin\Debug\staging\TestARMProject\Deploy-AzureResourceGroup.ps1' -StorageAccountName '' -ResourceGroupName 'TestARMProject' -ResourceGroupLocation 'eastus' -TemplateFile 'D:\Dev\local\TestARMProject\TestARMProject\bin\Debug\staging\TestARMProject\azuredeploy.json' -TemplateParametersFile 'D:\Dev\local\TestARMProject\TestARMProject\bin\Debug\staging\TestARMProject\azuredeploy.parameters.json' -ArtifactStagingDirectory '.' -DSCSourceFolder '.\DSC'
 - 
 - 
 - Account          : Frank Boucher
 - SubscriptionName : My Subscription
 - SubscriptionId   : xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 - TenantId         : xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
 - Environment      : AzureCloud
 - 
 - VERBOSE: Performing the operation "Replacing resource group ..." on target "".
 - VERBOSE: 7:06:33 - Created resource group 'TestARMProject' in location 'eastus'
 - 
 - ResourceGroupName : TestARMProject
 - Location          : eastus
 - ProvisioningState : Succeeded
 - Tags              : 
 - TagsTable         : 
 - ResourceId        : /subscriptions/xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/TestARMProject
 - 
 - Get-ChildItem : Cannot find path 
 - 'D:\Dev\local\TestARMProject\TestARMProject\bin\Debug\staging\TestARMProject\azuredeploy.json' because it does not 
 - exist.
 - At D:\Dev\local\TestARMProject\TestARMProject\bin\Debug\staging\TestARMProject\Deploy-AzureResourceGroup.ps1:108 
 - char:48
 - + ... RmResourceGroupDeployment -Name ((Get-ChildItem $TemplateFile).BaseNa ...
 - +                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~
 -     + CategoryInfo          : ObjectNotFound: (D:\Dev\local\Te...zuredeploy.json:String) [Get-ChildItem], ItemNotFound 
 -    Exception
 -     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
 -  
 - Deploying template using PowerShell script failed.
 - Tell us about your experience at https://go.microsoft.com/fwlink/?LinkId=691202
Apparently the script is failling with Get-ChildItem because my script is missing?! I looked in the folder D:\Dev\local\TestARMProject\TestARMProject\bin\Debug\staging\TestARMProject, and indeed the files are missing! Fixing this is in fact really simple fortunately.

The Solution


The problem is very simple when Visual Studio is building the project, it doen't copies the script files in the build folder (in this case bin\Debug\Staging\). In fact, Visual Studio is doing exactly as we are telling it. Let see the build command for those files. Right-click and select Properties (or Alt+Enter) while azuredeploy.json is selected.

Properties

See the Build Action is set at None change that to Content (for all the scripts). Save and Deploy again.

enjoy

Enjoy!



Reading Notes #309

419HCloud


Programming


Databases


Miscellaneous



Reading Notes #305

AzureDatabricks

Cloud


Programming


Miscellaneous


Reading Notes #301

300love

Programming


Data

Miscellaneous


  • My First Year as an MVP, part 1 (Jen Kuntz) - Interesting post. It feels soooooo familiar, and yet so far now. I look forward to meeting you in March fellow Canadian MVP.


Reading Notes #300

300loveCloud


Programming


Data


Miscellaneous



Reading Notes #295

Sketch002

Cloud


Programming


Databases




Reading Notes #292

cloudheight


Suggestion of the week


Cloud


Programming


Databases


Miscellaneous



Reading Notes #277

IMG_20170422_130532Cloud

Programming

Miscellaneous

  • Bots are the new Apps – Part 2 (Alexandre Brisebois) - This post asks a lot of questions. .Bots are could be very powerful but are they easy to build? Iterate, test, fail, learn, and try again.


Reading Notes #274

2017-04-03_5-57-51Suggestion of the week


Cloud


Programming



Reading Notes #273

Frank_AzureFunction-2Cloud


Programming


Miscellaneous



Reading Notes #272

Show_me_the_wayCloud


Programming


Databases



Reading Notes #271

vs2017

 

 

Suggestion of the week

  • Azure Functions vs Web Jobs: How to choose? (Chris Pietschmann) - Wow! This is the best post I've read about Azure Function. It really describes clearly the differences between the two. A must for every cloud developer.

Cloud


Programming


Databases


Miscellaneous




Reading Notes #267

IMG_20170208_201247Cloud


Programming


Miscellaneous




Reading Notes #259

three-amigos-mainCloud


Programming




Reading Notes #257

2016-11-20_21-14-57Suggestion of the week

  • Microsoft Connect(); 2016 Recap (Joseph Hill) - Three full day of great content. However, if you are like me, you didn't that much free time. Fortunately, all the presentations are available in video on demand. You need a summary because even if the keynote was really good... it is still 2h30, this post is the place to start.

Cloud


Programming


Miscellaneous



Reading Notes #256

IMG_20161107_104028Cloud

Programming

Miscellaneous



ReadingNotes #256


Cloud



Programming



Miscellaneous



Reading Notes #249

logicappSuggestion of the week


Cloud


Programming


Databases


Miscellaneous




Reading Notes #248

imageProgramming


Databases


Miscellaneous


Reading Notes #247

23Cloud


Programming


Miscellaneous