Not able to complete the ARM template deployment Visual studio code

Flávio Pena 0 Reputation points
2024-03-22T15:06:48.0866667+00:00

https://learn.microsoft.com/en-us/training/modules/create-azure-resource-manager-template-vs-code/3-exercise-create-and-deploy-template?pivots=powershell

I'm getting the below error when trying to run the scrip to deploy Arm template on Visual Studio code using the sandbox subscription

The json file has been created and saved locally azuredeploy.json

. connect-azaccount

 

. $context = Get-AzSubscription -SubscriptionId 1ca6bf90-05e5-401c-a602-4f23fb9fbda1

 Set-AzContext $context

 

. Set-AzDefault -ResourceGroupName learn-602c18e1-5f0a-4fac-91b0-cd84fb3c415e

 

 

. $templateFile="azuredeploy.json"

  $today=Get-Date -Format "03-22-2024"

  $deploymentName="blanktemplate-"+"$today"

  New-AzResourceGroupDeployment `

  -Name $deploymentName `

-TemplateFile $templateFile

 

 

 -Name : The term '-Name' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a

path was included, verify that the path is correct and try again.

At line:1 char:2

  •  -Name $deploymentName `
  •  ~~~~~

    + CategoryInfo          : ObjectNotFound: (-Name:String) [], CommandNotFoundException

    + FullyQualifiedErrorId : CommandNotFoundException

Azure Training
Azure Training
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.Training: Instruction to develop new skills.
1,313 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Srinud 2,040 Reputation points Microsoft Vendor
    2024-03-22T16:33:32.7933333+00:00

    Hi Flávio Miguel Pena,

    Thank you for reaching out to us on Microsoft Q&A forum.

    When you are using PowerShell the "present directory" or current working directory is where you should save your 'azuredeploy.json' file. It is the directory in which you are currently located when running commands in the terminal. 

    Here are some steps to clarify: 

    1.Create your Azure Resource Manager (ARM) Template 'azuredeploy.json': When you create your ARM template, save it in a directory of your choice on your local machine. For example, you might have a project folder where you keep all your code and related files. 

    2.Open PowerShell and navigate to the directory where you saved your 'azuredeploy.json' file. You can use the 'cd' command to change it to the appropriate directory as shown in the following screenshot:

    arm-4

    We have done practically from our end successfully, kindly follow the steps as per the exercise. Sharing the screenshot below for your reference:

    arm-1

    The final output will be in this format as shown in below screenshot:

    User's image

    Before creating resources in the Azure portal during exercises, make sure to choose the sandbox account. Confirm that the current directory matches the sandbox account; if not, switch directories.

    Note: Make sure that you are in "Microsoft Learn Sandbox" Directory in the Azure portal before the sandbox expires:

    User's image

    Please don't hesitate to reach out to us if you have any further queries with screenshots of the error (after hiding all PII).

    I hope the information provided has been helpful to you! If so, please accept the answer by clicking the "Upvote and Accept Answer" on the post. We value your feedback, and it will help to assist others who might have a similar query.

    Thank you.