简体   繁体   English

将 GitLab Web 应用程序部署到 Azure 应用程序服务

[英]Deploy GitLab web app to Azure app service

Hello guys am new with Gitlab and Azure , currently am having a repo on Gitlba and am trying to deploy it to Azure, but I can't manage to achieve this, tried to follow this link , but the information is old, Is there anyone with a latest link or resource to achieve this?大家好,我是 Gitlab 和 Azure 的新手,目前在 Gitlba 上有一个 repo 并正在尝试将其部署到 Azure,但我无法实现这一点,尝试按照此链接进行操作,但信息很旧,有没有人使用最新的链接或资源来实现这一目标?

Thanks谢谢

Joy 's answer above is helpful. Joy上面回答很有帮助。 I've rewritten it to clarify the steps on obtaining a SSH 'deploy key'.我已经重写它以阐明获取 SSH“部署密钥”的步骤。

  1. Head over to your Gitlab repository and click the Clone button.转到您的 Gitlab 存储库并单击克隆按钮。 Copy the Clone with SSH address.使用 SSH地址复制克隆

    Gitlab 存储库克隆按钮

    Also, have your Gitlab account username and password available.另外,请准备好您的 Gitlab 帐户用户名和密码。

  2. In the Azure portal go to your web app resource and go to the Deployment Center .在 Azure 门户中,转到您的 Web 应用资源并转到部署中心 Choose the External option.选择外部选项。 We're going to use the 'App Service build service'.我们将使用“应用服务构建服务”。 Next enter in the data from step 1. Click Continue to finish.接下来输入步骤 1 中的数据。单击继续完成。

    输入步骤 1 中的数据

  3. Next we're going to get the SSH 'deploy key'.接下来,我们将获得 SSH 的“部署密钥”。

    1. First go to the Properties page and copy the Deployment Trigger Url field.首先转到Properties页面并复制Deployment Trigger Url字段。
    2. Go back to the Deployment Center and click the Credentials button.返回到部署中心并单击凭据按钮。
    3. Insert these credentials into your copied url, like so: https://$mysite:BigRandomPassword@mysite.scm.azurewebsites.net/deploy将这些凭据插入您复制的 url,如下所示: https://$mysite:BigRandomPassword@mysite.scm.azurewebsites.net/deploy
    4. Take the full deploy URL above, and replace /deploy with /api/sshkey?ensurePublicKey=1 .获取上面的完整部署 URL,并将/deploy替换为/api/sshkey?ensurePublicKey=1 So it'll look like: https://$mysite:BigRandomPassword@mysite.scm.azurewebsites.net/api/sshkey?ensurePublicKey=1所以它看起来像: https://$mysite:BigRandomPassword@mysite.scm.azurewebsites.net/api/sshkey?ensurePublicKey=1
    5. Run curl on this URL, which returns an SSH public key.对这个 URL 运行 curl,它返回一个 SSH 公钥。 It's returned as a JSON string, so you'll need to remove the quotes.它作为 JSON 字符串返回,因此您需要删除引号。 It should look like:它应该看起来像:
      ssh-rsa AAAAB3NzaC1etc...
      Copy the key.复制密钥。

    ( These steps are from the Kudu docs ) 这些步骤来自Kudu 文档

  4. In GitLab go to Settings -> Repository -> Deploy Keys and click Expand .在 GitLab 中,转到Settings -> Repository -> Deploy Keys并单击Expand Add a title and the SSH 'deploy key' here.在此处添加标题和 SSH“部署密钥”。 Then save.然后保存。 Test it by going back to the Deployment Center in the Azure portal and clicking the Sync button.通过返回到 Azure 门户中的部署中心并单击同步按钮来测试它。 It should work.它应该工作。

    将部署密钥添加到 Gitlab

  5. Then we'll configure the continuous deployment.然后我们将配置持续部署。 In your GitLab go to Settings -> Integrations -> write the URL (This is the same Deployment Trigger URL in Properties we used earlier) To save click the Add webhook button.在您的 GitLab 中,转到设置->集成-> 写入URL (这与我们之前使用的属性中的部署触发器 URL相同)要保存,请单击添加 webhook按钮。

    添加 Gitlab 集成

  6. Create a new file (or commit a change) in the GitLab project and it deploys to the web app automatically.在 GitLab 项目中创建一个新文件(或提交更改),它会自动部署到 Web 应用程序。

The UI of the azure portal and the GitLab have changed, but the steps are still similar. azure 门户和 GitLab 的 UI 发生了变化,但步骤仍然相似。

The link in the comment is helpful, I test it and works fine.评论中的链接很有帮助,我测试了一下,效果很好。 In order to prevent the link from failing in the future, I made some summary as below.为了防止以后链接失效,我做了一些总结如下。

1.In the web app in the portal -> Deployment Center -> External -> App Service build service -> write the information as below -> next to finish. 1.在门户网站的web应用-> Deployment Center -> External -> App Service build service ->写如下信息->下一步完成。

在此处输入图片说明

The Repository you can get via the Clone button in your GitLab project, the Username and Password is the ones of your GitLab account.您可以通过 GitLab 项目中的Clone按钮获取RepositoryUsernamePassword是您的 GitLab 帐户的UsernamePassword

在此处输入图片说明

2.In your GitLab -> Settings -> Repository -> Deploy Keys -> Expand -> Add the key of the one in the https://<webapp-name>.scm.azurewebsites.net/api/sshkey?ensurePublicKey=1 ( ssh-rsa xxxxxx ). 2.在你的GitLab -> Settings -> Repository -> Deploy Keys -> Expand -> 添加https://<webapp-name>.scm.azurewebsites.net/api/sshkey?ensurePublicKey=1 ( ssh-rsa xxxxxx )。 Then you could test the Sync in the Deployment Center in the portal, it should work.然后您可以在门户中的Deployment Center测试Sync ,它应该可以工作。

3.Then we config the continuous deployment, in your GitLab -> Settings -> Integrations -> write the URL ( you can get it in the web app -> Properties -> Deployment Trigger URL ) -> Add webhook . 3.然后我们配置持续部署,在你的 GitLab -> Settings -> Integrations -> 写URL (你可以在 web app -> Properties -> Deployment Trigger URL ) -> Add webhook

4.Then I create a new file in the GitLab project, it deploys to the web app automatically. 4.然后我在 GitLab 项目中创建一个新文件,它会自动部署到 Web 应用程序。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM