Skip to content

Commit f7e1d81

Browse files
committed
Added edits and style changes to Azure web app guide
1 parent ea9be20 commit f7e1d81

1 file changed

Lines changed: 71 additions & 57 deletions

File tree

content/actions/guides/deploying-to-azure-app-service.md

Lines changed: 71 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,56 +11,69 @@ versions:
1111
{% data reusables.actions.enterprise-github-hosted-runners %}
1212

1313
### Introduction
14-
[Azure App Service](https://azure.microsoft.com/en-us/services/app-service/) is a Platform-as-a-Service (PaaS) offering from Microsoft, a “fully managed platform for building, deploying and scaling your web apps”. It is a great way to run web apps in several languages including JavaScript, which will be shown here.
1514

16-
This guide assumes you are in the directory of an existing [Node.js](https://nodejs.org/en/) project.
15+
This guide explains how to use {% data variables.product.prodname_actions %} to build, test, and deploy an application to [Azure App Service](https://azure.microsoft.com/en-us/services/app-service/).
16+
17+
Azure App Service can run web apps in several languages, but this guide demonstrates deploying an existing Node.js project.
1718

1819
### Prerequisites
19-
To adopt this workflow, you will first need to complete the following setup steps:
2020

21-
#### Create an App Service plan
22-
For example, after [authenticating](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli) with `az`, the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/):
21+
Before creating your {% data variables.product.prodname_actions %} workflow, you will first need to complete the following setup steps:
2322

24-
{% raw %}
25-
```bash{:copy}
26-
az appservice plan create \
27-
--resource-group $AZ_RESOURCE_GROUP \
28-
--name $AZ_APP_SERVICE_PLAN \
29-
--is-linux
30-
```
31-
{% endraw %}
23+
1. Create an Azure App Service plan.
3224

33-
where `$AZ_RESOURCE_GROUP` is a pre-existing Azure Resource Group and `$AZ_APP_SERVICE_PLAN` is a name of your choosing. If you need to set up a new Resource Group, follow [these instructions](https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest#az_group_create).
25+
For example, you can use the Azure CLI to create a new App Service plan:
3426

35-
#### Create a Web App
36-
Create an [App Service Web App](https://azure.microsoft.com/en-us/services/app-service/web/) with a [node runtime](https://docs.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest#az_webapp_list_runtimes), for example, using the Azure CLI:
27+
```bash{:copy}
28+
az appservice plan create \
29+
--resource-group MY_RESOURCE_GROUP \
30+
--name MY_APP_SERVICE_PLAN \
31+
--is-linux
32+
```
3733

38-
{% raw %}
39-
```bash{:copy}
40-
az webapp create \
41-
--name $AZURE_WEBAPP_NAME \
42-
--plan $AZ_APP_SERVICE_PLAN \
43-
--resource-group $AZ_RESOURCE_GROUP \
44-
--runtime "node|10.14"
45-
```
46-
{% endraw %}
34+
In the command above, replace `MY_RESOURCE_GROUP` with your pre-existing Azure Resource Group, and `MY_APP_SERVICE_PLAN` with a new name for the App Service plan.
35+
36+
See the Azure documentation for more information on using the [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/):
37+
38+
* For authentication, see "[Sign in with Azure CLI](https://docs.microsoft.com/en-us/cli/azure/authenticate-azure-cli)".
39+
* If you need to create a new resource group, see "[az group](https://docs.microsoft.com/en-us/cli/azure/group?view=azure-cli-latest#az_group_create)."
4740

48-
where `$AZURE_WEBAPP_NAME` is a webapp name of your choosing.
41+
2. Create a web app.
4942

50-
#### Configure publish profile and store as `AZURE_WEBAPP_PUBLISH_PROFILE` secret
51-
Next, we will generate Azure deployment credentials via a publish profile using [these instructions](https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials), adding them as a [GitHub repository secret](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets) named `AZURE_WEBAPP_PUBLISH_PROFILE`.
43+
For example, you can use the Azure CLI to create an Azure App Service web app with a node runtime:
5244

53-
### Workflow
54-
Now that the prerequisite steps are done, consider the following workflow, which will build, test, and deploy the Node.js project to Azure App Service.
45+
```bash{:copy}
46+
az webapp create \
47+
--name MY_WEBAPP_NAME \
48+
--plan MY_APP_SERVICE_PLAN \
49+
--resource-group MY_RESOURCE_GROUP \
50+
--runtime "node|10.14"
51+
```
52+
53+
In the command above, replace the parameters with your own values, where `MY_WEBAPP_NAME` is a new name for the web app.
54+
55+
3. Configure an Azure publish profile and create an `AZURE_WEBAPP_PUBLISH_PROFILE` secret.
56+
57+
Generate your Azure deployment credentials using a publish profile. For more information, see "[Generate deployment credentials](https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials)" in the Azure documentation.
58+
59+
In your {% data variables.product.prodname_dotcom %} repository, create a secret named `AZURE_WEBAPP_PUBLISH_PROFILE` that contains the contents of the publish profile. For more information on creating secrets, see "[Encrypted secrets](/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository)."
60+
61+
### Creating the workflow
62+
63+
Once you've completed the prerequisites, you can proceed with creating the workflow.
64+
65+
The following example workflow demonstrates how to build, test, and deploy the Node.js project to Azure App Service.
66+
67+
Ensure that you set `AZURE_WEBAPP_NAME` in the workflow `env` key to the name of the web app you created.
5568

5669
{% raw %}
57-
```bash{:copy}
70+
```yaml{:copy}
5871
on:
5972
release:
6073
types: [created]
6174
6275
env:
63-
AZURE_WEBAPP_NAME: your-app-name # set this to your application's name
76+
AZURE_WEBAPP_NAME: MY_WEBAPP_NAME # set this to your application's name
6477
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
6578
NODE_VERSION: '10.x' # set this to the node version to use
6679
@@ -69,33 +82,34 @@ jobs:
6982
name: Build and Deploy
7083
runs-on: ubuntu-latest
7184
steps:
72-
- uses: actions/checkout@v2
73-
74-
- name: Use Node.js ${{ env.NODE_VERSION }}
75-
uses: actions/setup-node@v1
76-
with:
77-
node-version: ${{ env.NODE_VERSION }}
78-
79-
- name: npm install, build, and test
80-
run: |
81-
# Build and test the project, then
82-
# deploy to Azure Web App.
83-
npm install
84-
npm run build --if-present
85-
npm run test --if-present
86-
87-
- name: 'Deploy to Azure WebApp'
88-
uses: azure/webapps-deploy@v2
89-
with:
90-
app-name: ${{ env.AZURE_WEBAPP_NAME }}
91-
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
92-
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
85+
- uses: actions/checkout@v2
86+
87+
- name: Use Node.js ${{ env.NODE_VERSION }}
88+
uses: actions/setup-node@v1
89+
with:
90+
node-version: ${{ env.NODE_VERSION }}
91+
92+
- name: npm install, build, and test
93+
run: |
94+
# Build and test the project, then
95+
# deploy to Azure Web App.
96+
npm install
97+
npm run build --if-present
98+
npm run test --if-present
99+
100+
- name: 'Deploy to Azure WebApp'
101+
uses: azure/webapps-deploy@v2
102+
with:
103+
app-name: ${{ env.AZURE_WEBAPP_NAME }}
104+
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
105+
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
93106
```
94107
{% endraw %}
95108

96109
### Additional resources
97-
The following additional resources may also be of use:
98110

99-
1. [Azure App Service starter workflow](https://github.com/actions/starter-workflows/blob/master/ci/azure.yml) for the full starter workflow
100-
1. [`Azure/webapps-deploy`](https://github.com/Azure/webapps-deploy), the Azure action used
101-
1. [App Service quickstart -- Node.js](https://docs.microsoft.com/en-us/azure/app-service/quickstart-nodejs) for a quickstart using the [VSCode Azure App Service extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureappservice)
111+
The following resources may also be useful:
112+
113+
* For the original starter workflow, see [`azure.yml`](https://github.com/actions/starter-workflows/blob/master/ci/azure.yml) in the {% data variables.product.prodname_actions %} `starter-workflows` repository.
114+
* The action used to deploy the web app is the official Azure [`Azure/webapps-deploy`](https://github.com/Azure/webapps-deploy) action.
115+
* The "[Create a Node.js web app in Azure](https://docs.microsoft.com/en-us/azure/app-service/quickstart-nodejs)" quickstart in the Azure web app documentation demonstrates using VS Code with the [Azure App Service extension](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureappservice).

0 commit comments

Comments
 (0)