Skip to content

Commit f6de384

Browse files
committed
edits
1 parent c823254 commit f6de384

File tree

1 file changed

+39
-21
lines changed

1 file changed

+39
-21
lines changed

articles/app-service/deploy-local-git.md

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,31 +17,49 @@ One of the simplest ways to deploy code is from your local computer. This articl
1717
1818
## Prerequisites
1919

20-
To complete the steps in this article:
20+
To complete the steps in this article, you need:
2121

22-
- [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
23-
24-
- [Install Git](https://www.git-scm.com/downloads), and have a local Git repository that contains app code to deploy.
22+
- [Git installed](https://www.git-scm.com/downloads), and a local Git repository that contains app code to deploy.
2523

2624
You can clone a sample Node.js app repository by running the following command in your local Bash terminal window:
2725

2826
```bash
2927
git clone https://github.com/Azure-Samples/nodejs-docs-hello-world.git
3028
```
3129

30+
# [Azure CLI](#tab/cli)
31+
32+
To run the Azure CLI commands, you need:
33+
34+
- An Azure account and subscription with permission to create App Services resources. [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
35+
- The latest version of the [Azure CLI](/cli/azure/install-azure-cli) installed on your local machine. Sign in to Azure using [az login](/cli/azure/reference-index#az-login).
36+
37+
# [Azure PowerShell](#tab/powershell)
38+
39+
To run the Azure PowerShell commands, you need:
40+
41+
- An Azure account and subscription with permission to create App Services resources. [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
42+
- The latest version of [Azure PowerShell](/powershell/azure/install-azure-powershell) installed. Sign in to Azure using [Connect-AzAccount](/powershell/module/az.accounts/connect-azaccount).
43+
44+
# [Azure portal](#tab/portal)
45+
46+
- An Azure account and subscription with permission to create App Services resources. [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
47+
3248
### Deployment user
3349

34-
You need deployment user credentials to deploy your app. The deployment user is different from your Azure account or subscription user. The deployment user can use either [user-scope](deploy-configure-credentials.md#userscope) or [application-scope](deploy-configure-credentials.md#appscope) credentials.
50+
You need deployment user credentials to deploy your app. The deployment user is different from the Azure subscription user, and can use either [user-scope](deploy-configure-credentials.md#userscope) or [application-scope](deploy-configure-credentials.md#appscope) credentials.
3551

36-
You can configure a user-scope deployment user by using Azure CLI or the Azure portal. Follow the instructions at [Configure user-scope credentials](deploy-configure-credentials.md#userscope). You only need a user name, not a password, to authenticate a local Git deployment user. You must have an existing app to create a user-scope deployment user, but you can then use that same user with all the App Service apps you have access to.
52+
You can create a user-scope deployment user by running the Azure CLI command `az webapp deployment user set --user-name <username>`. You can also create the user on the **Local Git/FTPS credentials** tab in the **Deployment Center** of any App Service app. You only need a user name, not a password, to create and authenticate a user-scope deployment user for local Git deployment.
3753

38-
An application-scope user is app-specific and is created automatically when you create the app. You can get the application-scope user credentials from the **Local Git/FTPS credentials** tab in the **Deployment Center** for your app.
54+
Once you create the user-scope deployment user, it applies to all the App Service apps in your subscription. For more information, see [Configure user-scope credentials](deploy-configure-credentials.md#userscope).
55+
56+
An application-scope user is app-specific and is created automatically when you create the app. You can get the application-scope user credentials to use for deployment from the **Local Git/FTPS credentials** tab in your app's **Deployment Center**.
3957

4058
[!INCLUDE [Prepare repository](../../includes/app-service-deploy-prepare-repo.md)]
4159

4260
## Create and configure a Git-enabled app
4361

44-
You can create and configure a Git-enabled app, or configure local Git deployment for a pre-existing app, by using Azure CLI, Azure PowerShell, or the Azure portal.
62+
You can create and configure a Git-enabled app, or configure local Git deployment for a preexisting app, by using Azure CLI, Azure PowerShell, or the Azure portal.
4563

4664
# [Azure CLI](#tab/cli)
4765

@@ -68,22 +86,23 @@ Use this Git clone URL to deploy your app in the next step.
6886

6987
# [Azure PowerShell](#tab/powershell)
7088

71-
1. To create a new web app, run [New-AzWebApp](/powershell/module/az.websites/new-azwebapp) from the root of your cloned Git repository. For example:
89+
1. In a local PowerShell terminal, change directory to the root of your cloned Git repository.
90+
1. To create a new web app, run [New-AzWebApp](/powershell/module/az.websites/new-azwebapp). For example:
7291

7392
```azurepowershell
7493
New-AzWebApp -Name myApp
7594
```
7695

7796
When you run this cmdlet from a directory that's a Git repository, it automatically creates a Git remote repository named `azure` for your App Service app.
7897

79-
1. Run the [Set-AzResource](/powershell/module/az.resources/set-azresource) cmdlet to set the `scmType` of your new or pre-existing app, for example:
98+
1. Run the [Set-AzResource](/powershell/module/az.resources/set-azresource) cmdlet to set the `scmType` of your new or preexisting app, for example:
8099

81100
```azurepowershell
82101
$PropertiesObject = @{
83102
scmType = "LocalGit";
84103
}
85104
86-
Set-AzResource -PropertyObject $PropertiesObject -ResourceGroupName myResourceGroup `
105+
Set-AzResource -PropertyObject $PropertiesObject -ResourceGroupName myapp `
87106
-ResourceType Microsoft.Web/sites/config -ResourceName myApp/web `
88107
-ApiVersion 2015-08-01 -Force
89108
```
@@ -101,7 +120,7 @@ When the app is created, select **Go to resource**.
101120

102121
### Configure local Git deployment
103122

104-
1. On the Azure portal page for your new or pre-existing app, select **Deployment Center** under **Deployment** in the left navigation menu.
123+
1. On the Azure portal page for your new or preexisting app, select **Deployment Center** under **Deployment** in the left navigation menu.
105124
1. On the **Settings** tab, select **Local Git** from the dropdown list next to **Source**, and then select **Save**.
106125

107126
:::image type="content" source="media/deploy-local-git/enable-portal.png" alt-text="Screenshot that shows how to enable local Git deployment for App Service in the Azure portal.":::
@@ -112,26 +131,25 @@ When the app is created, select **Go to resource**.
112131

113132
## Deploy the web app
114133

115-
To deploy the app to Azure, create a remote branch, make sure you're deploying to the correct branch, and then push your code to the remote.
134+
To deploy the app to Azure, create a remote branch if necessary, make sure you're deploying to the correct branch, and then push your code to the remote.
116135

117136
### Create the remote branch
118137

119-
1. In a local Bash terminal, change directory to the root of your cloned Git repository.
138+
If you used Azure PowerShell`New-AzWebApp` to create the app from the sample code, the `azure` remote was already created. Otherwise, follow these instructions to create the remote:
139+
140+
1. In a local terminal, change directory to the root of your cloned Git repository.
120141
1. Add a Git remote named `azure` by using your Git clone URL. If you don't know your Git clone URL, use `https://<app-name>.scm.azurewebsites.net/<app-name>.git`.
121142

122143
```bash
123144
git remote add azure <git-clone-url>
124145
```
125146

126-
>[!NOTE]
127-
>If you used Azure PowerShell`New-AzWebApp` to create the app, the `azure` remote was already created.
128-
129147
<a name="change-deployment-branch"></a>
130148
### Push to the correct branch
131149

132150
App Service repositories deploy files to the `master` branch by default. If your local code is in the `master` branch of your repository, you can now deploy your app by running `git push azure master`.
133151

134-
However, many Git repositories, including the sample code repository for this article, use `main` or another default branch name. To deploy to the correct branch, you must either explicitly deploy to the remote `master` branch, or change the deployment branch to `main` or other branch name and then deploy to that branch.
152+
However, many Git repositories, including the sample code repository for this article, use `main` or another default branch name. To deploy to the correct branch, you must either explicitly deploy to the remote `master` branch, or change the deployment branch to `main` or other branch name and deploy to that branch.
135153

136154
Explicitly deploy to `master` from your `main` branch by using the following `push` command:
137155

@@ -151,8 +169,8 @@ Or change your app's `DEPLOYMENT_BRANCH` app setting to `main` and then push dir
151169
- Azure portal:
152170

153171
1. On the portal page for your app, select **Environment variables** under **Settings** in the left navigation menu.
154-
1. Select **Add**, and add an application setting with the name *DEPLOYMENT_BRANCH* and the value *main*.
155-
1. In the Bash terminal, run `git push azure main`.
172+
1. Select **Add**, add an application setting with the name *DEPLOYMENT_BRANCH* and value *main*, and select **Apply**.
173+
1. In the terminal window, run `git push azure main`.
156174

157175
### Finish and verify the deployment
158176

@@ -171,7 +189,7 @@ The following common errors might occur when you use local Git to publish to an
171189
|`Unable to access '[siteURL]': Failed to connect to [scmAddress]`|The app isn't running.|In the Azure portal, start the app. Git deployment isn't available when the web app is stopped.|
172190
|`Couldn't resolve host 'hostname'`|The address information for the `azure` remote is incorrect.|Use the `git remote -v` command to list all remotes and their associated URLs. Verify that the URL for the `azure` remote is correct. If necessary, remove the incorrect URL by using `git remote remove` and then recreate the remote with the correct URL.|
173191
|`No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'main'.`|You didn't specify a branch when you ran `git push` or you didn't set the `push.default` value in `.gitconfig`.|Run `git push` again and specify the main branch with `git push azure main`.|
174-
|`Error - Changes committed to remote repository but deployment to website failed.`|You pushed a local branch that doesn't match the app deployment branch on `azure`.|Verify that the current branch is `master`, or change the deployment branch by following the instructions at [Change the deployment branch](#change-the-deployment-branch). |
192+
|`Error - Changes committed to remote repository but deployment to website failed.`|You pushed a local branch that doesn't match the app deployment branch on `azure`.|Verify that the current branch is `master`, or change the deployment branch by following the instructions at [Push to the correct branch](#push-to-the-correct-branch). |
175193
|`src refspec [branchname] does not match any.`|You tried to push to a branch other than `main` on the `azure` remote.|Run `git push` again, and specify the `main` branch with `git push azure main`.|
176194
|`RPC failed; result=22, HTTP code = 5xx.`|You tried to push a large Git repository over HTTPS.|Change the git configuration on the local computer to set a higher value for `postBuffer`. For example: `git config --global http.postBuffer 524288000`.|
177195
|`Error - Changes committed to remote repository but your web app not updated.`|You deployed a Node.js app with a *package.json* file that specifies added required modules.|Review the `npm ERR!` error messages that appear before this error for more context. The following known causes of this error produce the corresponding `npm ERR!` messages:<br />**Malformed package.json file**: `npm ERR! Couldn't read dependencies.`<br />**Native module doesn't have a binary distribution for Windows**: `npm ERR! \cmd "/c" "node-gyp rebuild"\ failed with 1`<br />or `npm ERR! [modulename@version] preinstall: \make \|\| gmake\` |

0 commit comments

Comments
 (0)