Skip to content

Commit c823254

Browse files
committed
edits
1 parent a79b28f commit c823254

File tree

1 file changed

+61
-41
lines changed

1 file changed

+61
-41
lines changed

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

Lines changed: 61 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,27 @@ To complete the steps in this article:
2121

2222
- [!INCLUDE [quickstarts-free-trial-note](~/reusable-content/ce-skilling/azure/includes/quickstarts-free-trial-note.md)]
2323

24-
- [Install Git](https://www.git-scm.com/downloads), and have a local Git repository with code to deploy.
24+
- [Install Git](https://www.git-scm.com/downloads), and have a local Git repository that contains app code to deploy.
2525

26-
To clone a sample repository, run the following command in your local terminal window:
26+
You can clone a sample Node.js app repository by running the following command in your local Bash terminal window:
2727

2828
```bash
2929
git clone https://github.com/Azure-Samples/nodejs-docs-hello-world.git
3030
```
3131

32-
- Configure a deployment user. You can use either [user-scope](deploy-configure-credentials.md#userscope) or [application-scope](deploy-configure-credentials.md#appscope) credentials to deploy your app.
32+
### Deployment user
3333

34-
- To configure a *user-scope deployment user* by using the Azure portal or Azure CLI, follow the instructions at [Configure user-scope credentials](#deploy-configure-credentials.md#userscope). You only need a user name, not a password, to create a local Git deployment user. The deployment user name is different from your Azure account user name. You can use the same App Service deployment user for all the apps in your Azure subscription.
35-
- An *application-scope user* is app-specific and is created automatically when you create an app. You can get the application-scope user credentials from the **Local Git/FTPS credentials** tab in the **Deployment Center** for your app.
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.
35+
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.
37+
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.
3639

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

3942
## Create and configure a Git-enabled app
4043

41-
You can create and configure a Git-enabled app by using Azure CLI, Azure PowerShell, or the Azure portal.
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.
4245

4346
# [Azure CLI](#tab/cli)
4447

@@ -59,89 +62,106 @@ Either command produces output that includes a URL, such as:
5962
```output
6063
Local git is configured with url of 'https://[email protected]/myApp.git'
6164
```
62-
The URL contains the user-scope deployment user name. If there's no user-scope deployment user name, the URL for the app uses the [application-scope user name](deploy-configure-credentials.md#appscope), for example `https://[email protected]/myApp.git`. Use this URL to deploy your app in the next step.
65+
The URL contains the user-scope deployment user name. If there's no user-scope deployment user name, the URL uses the [application-scope user name](deploy-configure-credentials.md#appscope), for example `https://[email protected]/myApp.git`.
66+
67+
Use this Git clone URL to deploy your app in the next step.
6368

6469
# [Azure PowerShell](#tab/powershell)
6570

66-
1. Run [New-AzWebApp](/powershell/module/az.websites/new-azwebapp) from the root of your cloned Git repository. For example:
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:
6772

6873
```azurepowershell
6974
New-AzWebApp -Name myApp
7075
```
7176

7277
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.
7378

74-
1. Set the `scmType` of your app by running the [Set-AzResource](/powershell/module/az.resources/set-azresource) cmdlet.
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:
7580

7681
```azurepowershell
7782
$PropertiesObject = @{
7883
scmType = "LocalGit";
7984
}
8085
81-
Set-AzResource -PropertyObject $PropertiesObject -ResourceGroupName <group-name> `
82-
-ResourceType Microsoft.Web/sites/config -ResourceName <app-name>/web `
86+
Set-AzResource -PropertyObject $PropertiesObject -ResourceGroupName myResourceGroup `
87+
-ResourceType Microsoft.Web/sites/config -ResourceName myApp/web `
8388
-ApiVersion 2015-08-01 -Force
8489
```
8590

8691
# [Azure portal](#tab/portal)
8792

88-
1. In the [Azure portal](https://portal.azure.com), create an App Service app by following any of the portal-based instructions under **Create your first app** at [Getting started with Azure App Service](getting-started.md). On the **Deployment** tab of the app creation screen, make sure to set **Basic Authentication** to **Enabled**.
89-
1. When the app is created, select **Go to resource**.
90-
1. Select **Deployment Center** under **Deployment** in the left navigation menu for the app.
93+
### Create the app
94+
95+
In the [Azure portal](https://portal.azure.com), create an App Service app by following any of the portal-based instructions under **Create your first app** at [Getting started with Azure App Service](getting-started.md).
96+
97+
- For the sample repository, use the [Node.js](getting-started.md?pivots=stack-nodejs#nodejs) instructions and select **Node 20 LTS** for **Runtime stack** on the **Basics** tab.
98+
- At the bottom of the **Deployment** tab on the **Create Web App** page, set **Basic Authentication** to **Enabled**.
99+
100+
When the app is created, select **Go to resource**.
101+
102+
### Configure local Git deployment
103+
104+
1. On the Azure portal page for your new or pre-existing app, select **Deployment Center** under **Deployment** in the left navigation menu.
91105
1. On the **Settings** tab, select **Local Git** from the dropdown list next to **Source**, and then select **Save**.
92106

93107
:::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.":::
94108

95-
1. The **Git clone URI** appears under **Local Git** on the **Settings** screen. This URI doesn't contain any sign-in information. Copy the value to use in the next step.
96-
97-
If you already have an App Service app to use, you can configure local Git deployment from the **Settings** tab of the app's **Deployment Center**. Copy the deployment URI.
109+
1. When the configuration completes, the **Git clone URI** appears under **Local Git** on the **Settings** screen. This URI doesn't contain any sign-in information. Copy the value to use in the next step.
98110

99111
-----
100112

101113
## Deploy the web app
102114

103-
1. In a local Bash terminal window, change directory to the root of your cloned Git repository.
104-
1. Add a Git remote by using the URL returned from configuring your app.
105-
- If you used Azure PowerShell`New-AzWebApp` to create the app, the remote is already created.
106-
- If the method you used didn't provide a URL, use `https://<app-name>.scm.azurewebsites.net/<app-name>.git` for the URL.
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.
116+
117+
### Create the remote branch
118+
119+
1. In a local Bash terminal, change directory to the root of your cloned Git repository.
120+
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`.
107121

108122
```bash
109-
git remote add azure <url>
123+
git remote add azure <git-clone-url>
110124
```
111125

112-
1. Push to the Azure remote branch by running `git push azure main`.
113-
1. If the **Git Credential Manager** dialog appears, enter your user-scope deployment user name or application-scope sign-in information. If your Git remote URL already contains the sign-in information, you aren't prompted to enter it.
114-
1. Review the output. You might see runtime-specific automation, such as `MSBuild` for ASP.NET, `npm install` for Node.js, or `pip install` for Python.
115-
1. If you get errors, see [Troubleshoot deployment](#troubleshoot-deployment) or [Change the deployment branch](#change-the-deployment-branch).
116-
1. In the Azure portal, verify that the app deployed successfully by selecting the **Default domain** link on the app's **Overview** page. The app should open in a browser tab and display **Hello World!**.
126+
>[!NOTE]
127+
>If you used Azure PowerShell`New-AzWebApp` to create the app, the `azure` remote was already created.
117128
118129
<a name="change-deployment-branch"></a>
119-
## Change the deployment branch
130+
### Push to the correct branch
120131

121-
When you push commits to your `azure` App Service repository, App Service deploys the files in the `master` branch by default. Many Git repositories, including the sample code repository for this article, use `main` as the default branch. You must ensure that you push to the correct branch in the App Service repository by taking one of the following steps:
132+
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`.
122133

123-
- Explicitly deploy to `master` instead of `main` by using the following `push` command:
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.
124135

125-
```bash
126-
git push azure main:master
127-
```
136+
Explicitly deploy to `master` from your `main` branch by using the following `push` command:
137+
138+
```bash
139+
git push azure main:master
140+
```
128141

129-
- Change the `DEPLOYMENT_BRANCH` app setting to `main` before you push the commit to `main`.
142+
Or change your app's `DEPLOYMENT_BRANCH` app setting to `main` and then push directly to `main`, as follows:
130143

131-
- Azure CLI:
144+
- Azure CLI:
132145

133146
```azurecli
134147
az webapp config appsettings set --name <app-name> --resource-group <group-name> --settings DEPLOYMENT_BRANCH='main'
135148
git push azure main
136149
```
137150

138-
Azure portal:
151+
- Azure portal:
139152

140153
1. On the portal page for your app, select **Environment variables** under **Settings** in the left navigation menu.
141-
1. On the **Environmental variables** page, select **Add**.
142-
1. On the **Add/edit application setting** screen, enter *DEPLOYMENT_BRANCH* for **Name** and *main* for **Value**, and then select **Apply**.
154+
1. Select **Add**, and add an application setting with the name *DEPLOYMENT_BRANCH* and the value *main*.
143155
1. In the Bash terminal, run `git push azure main`.
144156

157+
### Finish and verify the deployment
158+
159+
After you push your code, if the **Git Credential Manager** dialog appears, enter your user-scope deployment user name or application-scope user name and password. If your Git remote URL already contains the sign-in information, you aren't prompted to enter it.
160+
161+
Review the output from the `push` command. You might see runtime-specific automation, such as `npm install` for Node.js, `MSBuild` for ASP.NET, or `pip install` for Python. If you get errors, see [Troubleshoot deployment](#troubleshoot-deployment).
162+
163+
Go to the Azure portal and verify that the app deployed successfully by selecting the **Default domain** link on the app's **Overview** page. The app should open in a browser tab and display **Hello World!**.
164+
145165
## Troubleshoot deployment
146166

147167
The following common errors might occur when you use local Git to publish to an App Service app in Azure:
@@ -152,9 +172,9 @@ The following common errors might occur when you use local Git to publish to an
152172
|`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.|
153173
|`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`.|
154174
|`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). |
155-
|`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`.|
156-
|`RPC failed; result=22, HTTP code = 5xx.`|You might have 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`.|
157-
|`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 causes are known causes of this error and 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` or `npm ERR! [modulename@version] preinstall: \make \|\| gmake\` |
175+
|`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`.|
176+
|`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`.|
177+
|`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\` |
158178

159179
## Related content
160180

0 commit comments

Comments
 (0)