You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
(Optional) This article uses a GitHub template repository as another way to make it easy for you to get started. The template features a starter app to deploy to Azure Static Web Apps.
31
44
32
-
Now that the repository is generated from the template, you can deploy the app as a static web app from the Azure CLI.
45
+
1. Navigate to the following location to create a new repository: https://github.com/staticwebdev/vanilla-basic/generate.
46
+
2. Name your repository `my-first-static-web-app`.
33
47
34
-
1. Sign in to the Azure CLI by using the following command.
48
+
> [!NOTE]
49
+
> Azure Static Web Apps requires at least one HTML file to create a web app. The repository you create in this step includes a single `index.html` file.
35
50
36
-
```azurecli
37
-
az login
38
-
```
51
+
3. Select **Create repository**.
52
+
53
+
## Deploy a Static Web App
54
+
55
+
Deploy the app as a static web app from the Azure CLI.
39
56
40
57
1. Create a resource group.
41
58
42
-
```azurecli
43
-
az group create \
44
-
--name my-swa-group \
45
-
--location "eastus2"
46
-
```
47
-
48
-
1. Create a variable to hold your GitHub user name.
49
-
50
-
Before you execute the following command, replace the placeholder `<YOUR_GITHUB_USER_NAME>` with your GitHub user name.
51
-
52
-
```bash
53
-
GITHUB_USER_NAME=<YOUR_GITHUB_USER_NAME>
54
-
```
55
-
56
-
1. Deploy a new static web app from your repository.
> The URL passed to the `--source` parameter must not include the `.git` suffix.
131
-
132
-
As you execute this command, the CLI starts the GitHub interactive log in experience. Look for a line in your console that resembles the following message.
133
-
134
-
> Go to `https://github.com/login/device` and enter the user code 329B-3945 to activate and retrieve your GitHub personal access token.
135
-
136
-
1. Go to **https://github.com/login/device**.
137
-
138
-
1. Enter the user code as displayed your console's message.
2. Deploy a new static web app from your repository.
82
+
83
+
```bash
84
+
az staticwebapp create \
85
+
--name $MY_STATIC_WEB_APP_NAME \
86
+
--resource-group $MY_RESOURCE_GROUP_NAME \
87
+
--location $REGION
88
+
```
145
89
146
90
There are two aspects to deploying a static app. The first operation creates the underlying Azure resources that make up your app. The second is a workflow that builds and publishes your application.
147
91
148
92
Before you can go to your new static site, the deployment build must first finish running.
149
93
150
-
1. Return to your console window and run the following command to list the URLs associated with your app.
94
+
3. Return to your console window and run the following command to list the website's URL.
1. Copy the **repository URL** and paste it into your browser.
127
+
```bash
128
+
echo"You can now visit your web server at https://$MY_STATIC_WEB_APP_URL"
129
+
```
161
130
162
-
1. Select the **Actions** tab.
131
+
## Use a GitHub template
163
132
164
-
At this point, Azure is creating the resources to support your static web app. Wait until the icon next to the running workflow turns into a check mark with green background (:::image type="icon" source="media/get-started-cli/checkmark-green-circle.png" border="false":::). This operation may take a few minutes to complete.
133
+
You've successfully deployed a static web app to Azure Static Web Apps using the Azure CLI. Now that you have a basic understanding of how to deploy a static web app, you can explore more advanced features and functionality of Azure Static Web Apps.
165
134
166
-
Once the success icon appears, the workflow is complete and you can return back to your console window.
135
+
In case you want to use the GitHub template repository, follow these steps:
167
136
168
-
1. Run the following command to query for your website's URL.
137
+
Go to https://github.com/login/device and enter the code you get from GitHub to activate and retrieve your GitHub personal access token.
169
138
170
-
```azurecli
171
-
az staticwebapp show \
172
-
--name my-first-static-web-app \
173
-
--query "defaultHostname"
174
-
```
139
+
1. Go to https://github.com/login/device.
140
+
2. Enter the user code as displayed your console's message.
141
+
3. Select `Continue`.
142
+
4. Select `Authorize AzureAppServiceCLI`.
175
143
176
-
Copy the URL into your browser to go to your website.
144
+
### View the Website via Git
177
145
178
-
## Clean up resources
146
+
1. As you get the repository URL while running the script, copy the repository URL and paste it into your browser.
147
+
2. Select the `Actions` tab.
179
148
180
-
If you're not going to continue to use this application, you can delete the resource group and the static web app by running the following command:
149
+
At this point, Azure is creating the resources to support your static web app. Wait until the icon next to the running workflow turns into a check mark with green background. This operation might take a few minutes to execute.
181
150
182
-
```azurecli
183
-
az group delete \
184
-
--name my-swa-group
151
+
3. Once the success icon appears, the workflow is complete and you can return back to your console window.
152
+
4. Run the following command to query for your website's URL.
153
+
```bash
154
+
az staticwebapp show \
155
+
--name $MY_STATIC_WEB_APP_NAME \
156
+
--query "defaultHostname"
185
157
```
158
+
5. Copy the URL into your browser to go to your website.
159
+
160
+
## Clean up resources (optional)
161
+
162
+
If you're not going to continue to use this application, delete the resource group and the static web app using the [az group delete](/cli/azure/group#az-group-delete) command.
0 commit comments