How to create a web app using code

61308555 25 Reputation points
2023-11-22T01:38:40.91+00:00
Hi there,

I'm attempting to create a web app using code. I have a JSON template, a parameters template and a Powershell script to deploy the template. I am getting an error when I go to deploy the template using the script which is as follows:

Line |

4 | New-AzResourceGroupDeployment `

| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

| 4:09:27 PM - Error: Code=InvalidDeployment; Message=The deployment 'createwebdev' must have either the TemplateLink or

| Template property set. Please see https://aka.ms/arm-module for usage details.

I don't know enough about what I'm doing to fix the error.

The code I have is as follows. Could someone please be kind enough to help me?

{
"$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"type": "string"
},
"location": {
"type": "string"
},
"sku": {
"type": "string"
},
"skucode": {
"type": "string"
}
},
"resources": [
{
"apiVersion": "2021-01-01",
"name": "[parameters('name')]",
"type": "Microsoft.Web/staticSites",
"location": "[parameters('location')]",
"tags": null,
"properties": {},
"sku": {
"tier": "[parameters('sku')]",
"name": "[parameters('skucode')]"
}
}
]
}

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "createwebdev"
},
"location": {
"value": "australiaeast"
},
"sku": {
"value": "Basic"
},
"skucode": {
"value": "B1"
}
  }
}

$rg = 'myresourcegroup'
New-AzResourceGroup -Name $rg -Location australiaeast -Force
New-AzResourceGroupDeployment `
-Name 'createwebdev' `
-ResourceGroupName $rg `
-TemplateFile 'webapp.json' `
-TemplateParameterFile 'webappParameters.json'

If I put the code into the 'Deploy Custom Template' section on Azure Portal it keeps telling me firstly that I cannot use australiaeast as the location and secondly that the SKU name is wrong and that I can only use Free, Standard or Trial, but when I attempt to use any of these it still fails.
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
838 questions
0 comments No comments
{count} votes

Accepted answer
  1. VenkateshDodda-MSFT 19,641 Reputation points Microsoft Employee
    2023-11-22T07:45:08.0866667+00:00

    @61308555 Thanks for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    Based on the shared information, we understand that you are trying to create a static webapp using the above ARM template.

    Static webapps service is offered in two different family sku's free, Standard and there are no other sku families like Basic or others. It is mentioned in the documentation as well.

    For sku and skucode parameters the supported values are either Free or Standard since you are passing Basic, B1 deployment is getting failed.

    Feel free to reach back to me if you have any further questions on this.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful