Error while provisioning Azure Static Web App via Powershell

Gurbakhshish Singh 0 Reputation points
2023-01-30T18:00:54.54+00:00

I am trying to create an Azure Static web app via Powershell command az staticwebapp create -n MyStaticAppName -g MyExistingRg in the Azure Devops pipeline but getting the error that source, location and branch are the required arguments but this command is working fine in the Azure portal command prompt. I am taking reference from https://learn.microsoft.com/en-us/cli/azure/staticwebapp?view=azure-cli-latest#az-staticwebapp-show

Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
770 questions
{count} votes

2 answers

Sort by: Most helpful
  1. VenkateshDodda-MSFT 18,441 Reputation points Microsoft Employee
    2023-01-31T05:27:33.0566667+00:00

    @Gurbakhshish Singh Thank you for reaching out to Microsoft Q&A, apologize for any inconvenience caused on this.

    To test this behavior, I have created a release pipeline with empty job, added Azure CLI task and by using the below cmdlet I am able to deploy the static webapp successfully.

    Azure CLI cmdlet used:

    az staticwebapp create -n qatestchecker -g mytestresourcegroup

    Sample output for reference:
    User's image

    If you want to deploy the static webapp using the PowerShell cmdlet New-AzStaticWebApp from your devops pipeline, then you need to Azure Powershell task and use the below cmdlet.

    New-AzStaticWebApp -ResourceGroupName '<ResourceGroupName>' -Location 'central us' -Name '<staticwebappName>' -SkuName 'Standard' -AppLocation './src' -ApiLocation ' ' -OutputLocation './src'

    Sample output for reference:
    User's image

    Note:

    Change the values for the parameters applocation, apilocation and outputlocation based on the which framework you want to deploy your static webapp.

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

    0 comments No comments

  2. Luke Murray 10,526 Reputation points MVP
    2023-01-31T05:36:25.27+00:00

    Hi, Gurbakhsish.

    You can deploy Azure Static WebApps directly from an Azure pipeline. When you stand up an Azure Static WebApp in Azure, it will allow you to create the pipeline.

    https://learn.microsoft.com/en-us/azure/static-web-apps/get-started-portal?tabs=vanilla-javascript&pivots=azure-devops

    https://dotnetthoughts.net/deploying-a-static-webapp-via-azure-devops-pipeline/

    https://gist.github.com/lukemurraynz/3f300a5eb73b2693d3a9378261a023db

    0 comments No comments