Deploy an App Service (Web App) with GitLab
App Service comes with Deployment Source which we can deploy our source code from many repository such as Github, Bitbucket or Dropbox. But there's no built-in support for GitLab. If we chose to use External Repository option, it'll support only for the public repository. So this will guide the steps we should take inorder to make our Web App (or any App Service) in Microsoft Azure connect to our private GitLab repository.
Set up a Local Git Repository
We need to setup a local git repository as a Deployment Source
to our App Service inorder to use GitLab.
- Select a Local Git Repository as a Deployment Source.
- Looking for a Deployment Trigger URL and copy it for later use. The hook URL is the /deploy path on the Kudu service. So it looks like
https://$user:[email protected]/deploy
.
- Take the full deploy URL above, and replace
/deploy
with/api/sshkey?ensurePublicKey=1
. So it'll look likehttps://$mysite:[email protected]/api/sshkey?ensurePublicKey=1
.
Set up an SSH deploy key
- Use the URL above to make a web request, may put into the Chrome Web Browser's address bar, which returns an SSH public key.
- From your GitLab repository select the menu
Deploy Keys
.
- Set this string as a 'deploy key' on your GitLab repository.
Set up a Web Hook
Set up a Web Hook so Kudu gets notified when a deployment happens.
- Use the Deployment Trigger URL above to add as a Web Hook in GitLab repository.
- Select the menu
Webhooks
.
- Set this URL to the GitLab.
Setting up an URL to GitLab repository
This part will guide to to set up continuous deployment using Resource Explorer
- Go to https://resources.azure.com/
- Find your site, either using the search UI or by expand the tree
- Under the site, open up the sourcecontrols/web node in the tree.
- Click on the Edit button (you may need to first set Explorer to Read/Write mode)
- Set the repoUrl property to your repo, e.g.
"repoUrl": "https://github.com/davidebbo-test/Hello_World_Demo",
- (optional) if you want to use a non-default branch, set the "branch" property as well
- Click the PUT button to apply the change.
- You're done! Now if you go to the portal, you should see that the site is hooked up, and the initial commit will get deployed
It might have some error when you PUT the
repoURL
in Resource Explorer, it's OK, let it be!