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
- 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
33
33
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.
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.
42
45
43
46
# [Azure CLI](#tab/cli)
44
47
@@ -59,89 +62,106 @@ Either command produces output that includes a URL, such as:
59
62
```output
60
63
Local git is configured with url of 'https://[email protected]/myApp.git'
61
64
```
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.
63
68
64
69
# [Azure PowerShell](#tab/powershell)
65
70
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:
67
72
68
73
```azurepowershell
69
74
New-AzWebApp -Name myApp
70
75
```
71
76
72
77
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.
73
78
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:
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.
91
105
1. On the **Settings** tab, select **Local Git** from the dropdown list next to **Source**, and then select **Save**.
92
106
93
107
:::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.":::
94
108
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.
98
110
99
111
-----
100
112
101
113
## Deploy the web app
102
114
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`.
107
121
108
122
```bash
109
-
git remote add azure <url>
123
+
git remote add azure <git-clone-url>
110
124
```
111
125
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.
117
128
118
129
<aname="change-deployment-branch"></a>
119
-
##Change the deployment branch
130
+
### Push to the correct branch
120
131
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`.
122
133
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.
124
135
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
+
```
128
141
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:
130
143
131
-
- Azure CLI:
144
+
- Azure CLI:
132
145
133
146
```azurecli
134
147
az webapp config appsettings set --name <app-name> --resource-group <group-name> --settings DEPLOYMENT_BRANCH='main'
135
148
git push azure main
136
149
```
137
150
138
-
Azure portal:
151
+
- Azure portal:
139
152
140
153
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*.
143
155
1. In the Bash terminal, run `git push azure main`.
144
156
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
+
145
165
## Troubleshoot deployment
146
166
147
167
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
152
172
|`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.|
153
173
|`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`.|
154
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). |
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\`|
0 commit comments