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.
29
44
30
-
## Deploy a static web app
45
+
- Navigate to the following location to create a new repository: https://github.com/staticwebdev/vanilla-basic/generate
46
+
- Name your repository `my-first-static-web-app`
31
47
32
-
Now that the repository is generated from the template, you can deploy the app as a static web app from the Azure CLI.
48
+
> **Note:** 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.
33
49
34
-
1. Sign in to the Azure CLI by using the following command.
50
+
Select **Create repository**.
35
51
36
-
```azurecli
37
-
az login
38
-
```
52
+
## Deploy a Static Web App
53
+
54
+
Deploy the app as a static web app from the Azure CLI.
39
55
40
56
1. Create a resource group.
41
57
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.
81
+
82
+
```bash
83
+
az staticwebapp create \
84
+
--name $MY_STATIC_WEB_APP_NAME \
85
+
--resource-group $MY_RESOURCE_GROUP_NAME \
86
+
--location $REGION
87
+
```
145
88
146
89
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
90
148
91
Before you can go to your new static site, the deployment build must first finish running.
149
92
150
-
1. Return to your console window and run the following command to list the URLs associated with your app.
93
+
3. Return to your console window and run the following command to list the website's URL.
echo"You can now visit your web server at https://$MY_STATIC_WEB_APP_URL"
128
+
```
163
129
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.
130
+
## Next Steps
165
131
166
-
Once the success icon appears, the workflow is complete and you can return back to your console window.
132
+
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.
167
133
168
-
1. Run the following command to query for your website's URL.
134
+
In case you want to use the GitHub template repository, follow these steps:
169
135
170
-
```azurecli
171
-
az staticwebapp show \
172
-
--name my-first-static-web-app \
173
-
--query "defaultHostname"
174
-
```
136
+
Go to https://github.com/login/device and enter the user code 329B-3945 to activate and retrieve your GitHub personal access token.
175
137
176
-
Copy the URL into your browser to go to your website.
138
+
1. Go to https://github.com/login/device.
139
+
2. Enter the user code as displayed your console's message.
140
+
3. Select `Continue`.
141
+
4. Select `Authorize AzureAppServiceCLI`.
177
142
178
-
## Clean up resources
143
+
### View the Website via Git
144
+
145
+
1. As you get the repository URL while running the script, copy the repository URL and paste it into your browser.
146
+
2. Select the `Actions` tab.
179
147
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:
148
+
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
149
182
-
```azurecli
183
-
az group delete \
184
-
--name my-swa-group
150
+
3. Once the success icon appears, the workflow is complete and you can return back to your console window.
151
+
4. Run the following command to query for your website's URL.
152
+
```bash
153
+
az staticwebapp show \
154
+
--name $MY_STATIC_WEB_APP_NAME \
155
+
--query "defaultHostname"
185
156
```
157
+
5. Copy the URL into your browser to go to your website.
158
+
159
+
## Clean up resources
160
+
161
+
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