The Problem
In a solution, I added a simple Azure Resource Group deployment project just like this one.
Then when I try to right-click and do a 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.See the Build Action is set at
None
change that to Content (for all the scripts). Save and Deploy again.Enjoy!