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
- 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
+
32
48
### Deployment user
33
49
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.
35
51
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.
37
53
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**.
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.
45
63
46
64
# [Azure CLI](#tab/cli)
47
65
@@ -68,22 +86,23 @@ Use this Git clone URL to deploy your app in the next step.
68
86
69
87
# [Azure PowerShell](#tab/powershell)
70
88
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:
72
91
73
92
```azurepowershell
74
93
New-AzWebApp -Name myApp
75
94
```
76
95
77
96
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.
78
97
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:
@@ -101,7 +120,7 @@ When the app is created, select **Go to resource**.
101
120
102
121
### Configure local Git deployment
103
122
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.
105
124
1. On the **Settings** tab, select **Local Git** from the dropdown list next to **Source**, and then select **Save**.
106
125
107
126
:::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**.
112
131
113
132
## Deploy the web app
114
133
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.
116
135
117
136
### Create the remote branch
118
137
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.
120
141
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`.
121
142
122
143
```bash
123
144
git remote add azure <git-clone-url>
124
145
```
125
146
126
-
>[!NOTE]
127
-
>If you used Azure PowerShell`New-AzWebApp` to create the app, the `azure` remote was already created.
128
-
129
147
<aname="change-deployment-branch"></a>
130
148
### Push to the correct branch
131
149
132
150
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`.
133
151
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.
135
153
136
154
Explicitly deploy to `master` from your `main` branch by using the following `push` command:
137
155
@@ -151,8 +169,8 @@ Or change your app's `DEPLOYMENT_BRANCH` app setting to `main` and then push dir
151
169
- Azure portal:
152
170
153
171
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`.
156
174
157
175
### Finish and verify the deployment
158
176
@@ -171,7 +189,7 @@ The following common errors might occur when you use local Git to publish to an
171
189
|`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.|
172
190
|`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.|
173
191
|`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). |
175
193
|`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
194
|`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
195
|`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