Skip to content

Latest commit

 

History

History
58 lines (40 loc) · 2.33 KB

File metadata and controls

58 lines (40 loc) · 2.33 KB
author cjk7989
ms.author jikunchen
ms.service azure-static-web-apps
ms.topic include
ms.date 07/02/2024

Create a static web app on Azure

You can create a static web app using the Azure portal, Azure CLI, Azure PowerShell, or Visual Studio Code (with the Azure Static Web Apps extension). This tutorial uses the Azure CLI.

  1. Sign into the Azure CLI:

    az login

    By default, this command opens a browser to complete the process. The Azure CLI supports various methods for signing in if this method doesn't work in your environment.

  2. If you have multiple subscriptions, you might need to select a subscription. You can view your current subscription using the following command:

    az account show

    To select a subscription, you can run the az account set command.

    az account set --subscription "<SUBSCRIPTION_NAME_OR_ID>"
  3. Create a resource group.

    Resource groups are used to group Azure resources together.

    az group create -n swa-tutorial -l centralus --query "properties.provisioningState"

    The -n parameter refers to the site name, and the -l parameter is the Azure location name. The command concludes with --query "properties.provisioningState" so the command only returns a success or error message.

  4. Create a static web app in your newly created resource group.

    az staticwebapp create -n swa-demo-site -g swa-tutorial --query "defaultHostname"

    The -n parameter refers to the site name, and the -g parameter refers to the name of the Azure resource group. Make sure you specify the same resource group name as in the previous step. Your static web app is globally distributed, so the location isn't important to how you deploy your app.

    The command is configured to return the URL of your web app. You can copy the value from your terminal window to your browser to view your deployed web app.