-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeFromLocalGitToAzure.txt
More file actions
92 lines (84 loc) · 6.45 KB
/
CodeFromLocalGitToAzure.txt
File metadata and controls
92 lines (84 loc) · 6.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
How to deploy your code through Local Git
Prerequisites
To complete this tutorial, you need:
• Git. You can download the installation binary here.
• Basic knowledge of Git.
• A Microsoft Azure account. If you don't have an account, you can sign up for a free trial or activate your Visual Studio subscriber benefits.
Note:
If you want to get started with Azure App Service before signing up for an Azure account, go to Try App Service, where you can immediately create a short-lived starter app in App Service. No credit cards required; no commitments.
Step 1: Create a local repository
Perform the following tasks to create a new Git repository.
1. Start a command-line tool, such as GitBash (Windows) or Bash (Unix Shell). On OS X systems you can access the command-line through the Terminalapplication.
2. Navigate to the directory where the content to deploy would be located.
3. Use the following command to initialize a new Git repository:
Command to enter in Bash/CLI
git init
Step 2: Commit your content
App Service supports applications created in a variety of programming languages.
1. If your repository already includes content skip this point and move to point 2 below. If your repository does not already include content simply populate with a static .html file as follows:
• Using a text editor, create a new file named index.html at the root of the Git repository
• Add the following text as the contents for the index.html file and save it: Hello Git!
2. From the command-line, verify that you are under the root of your Git repository. Then use the following command to add files to your repository:
Command to enter in Bash/CLI
git add -A
1. Next, commit the changes to the repository by using the following command:
Command to enter in Bash/CLI
git commit -m "Hello Azure App Service"
Step 3: Enable the App Service app repository
Perform the following steps to enable a Git repository for your App Service app.
1. Log in to the Azure Portal.
2. In your App Service app's blade, click Settings > Deployment source. Click Choose source, then click Local Git Repository, and then click OK.
3. If this is your first time setting up a repository in Azure, you need to create login credentials for it. You will use them to log into the Azure repository and push changes from your local Git repository. From your app's blade, click Deployment > Deployment credentials, then configure your deployment username and password. When you're done, click Save.
Step 4: Deploy your project
Use the following steps to publish your app to App Service using Local Git.
1. In your app's blade in the Azure Portal, click Settings > Properties for the Git URL.
Git URL is the remote reference to deploy to from your local repository. You'll use this URL in the following steps.
2. Using the command-line, verify that you are in the root of your local Git repository.
3. Use git remote to add the remote reference listed in Git URL from step 1. Your command will look similar to the following:
Command to enter in Bash/CLI
git remote add azure https://<username>@localgitdeployment.scm.azurewebsites.net:443/localgitdeployment.git
Note:
The remote command adds a named reference to a remote repository. In this example, it creates a reference named 'azure' for your web app's repository.
4. Push your content to App Service using the new azure remote you just created.
Command to enter in Bash/CLI
git push azure master
You will be prompted for the password you created earlier when you reset your deployment credentials in the Azure Portal. Enter the password (note that Gitbash does not echo asterisks to the console as you type your password).
1. Go back to your app in the Azure Portal. A log entry of your most recent push should be displayed in the Deployments blade.
2. Click the Browse button at the top of the app's blade to verify the content has been deployed.
Troubleshooting
The following are errors or problems commonly encountered when using Git to publish to an App Service app in Azure:
________________________________________
Symptom: Unable to access '[siteURL]': Failed to connect to [scmAddress]
Cause: This error can occur if the app is not up and running.
Resolution: Start the app in the Azure Portal. Git deployment will not work unless the app is running.
________________________________________
Symptom: Couldn't resolve host 'hostname'
Cause: This error can occur if the address information entered when creating the 'azure' remote was incorrect.
Resolution: Use the git remote -v command to list all remotes, along with the associated URL. Verify that the URL for the 'azure' remote is correct. If needed, remove and recreate this remote using the correct URL.
________________________________________
Symptom: No refs in common and none specified; doing nothing. Perhaps you should specify a branch such as 'master'.
Cause: This error can occur if you do not specify a branch when performing a git push operation, and have not set the push.default value used by Git.
Resolution: Perform the push operation again, specifying the master branch. For example:
Command to enter in Bash/CLI
git push azure master
________________________________________
Symptom: src refspec [branchname] does not match any.
Cause: This error can occur if you attempt to push to a branch other than master on the 'azure' remote.
Resolution: Perform the push operation again, specifying the master branch. For example:
Command to enter in Bash/CLI
git push azure master
________________________________________
Symptom: RPC failed; result=22, HTTP code = 502.
Cause: This error can occur if you attempt to push a large git repository over HTTPS.
Resolution: Change the git configuration on the local machine to make the postBuffer bigger
Command to enter in Bash/CLI
git config --global http.postBuffer 524288000
________________________________________
Symptom: Error - Changes committed to remote repository but your web app not updated.
Cause: This error can occur if you are deploying a Node.js app containing a package.json file that specifies additional required modules.
Resolution: Additional messages containing 'npm ERR!' should be logged prior to this error, and can provide additional context on the failure. The following are known causes of this error and the corresponding 'npm ERR!' message:
• Malformed package.json file: npm ERR! Couldn't read dependencies.
• Native module that does not have a binary distribution for Windows:
o npm ERR! `cmd "/c" "node-gyp rebuild"` failed with 1
OR
o npm ERR! [modulename@version] preinstall: `make || gmake`