But as there is no provider for GitLab, and none of the existing providers accept a GitLab URL, I'm unsure of how to proceed. I've looked at setting up a manual deployment with GitLab in the Azure Portal (using the External Repository option) and exporting the resource group template to get details of how the repository is connected to the App, but I get the error:Could not get resources of the type 'Microsoft.Web/sites/sourcecontrols'. Resources of this type will not be exported. (Code: ExportTemplateProviderError, Target: Microsoft.Web/sites/sourcecontrols)目前,我正在通过镜像GitHub中的GitLab存储库并使用从那里到Azure的连续部署管道来解决此问题.请注意,这是针对GitLab.com中托管的存储库,而不是针对自托管的GitLab服务器中的存储库.该项目没有Windows Runner安装程序.At the minute, I'm working around this by mirroring my GitLab repository in GitHub, and using the continuous deployment pipeline from there to Azure. Note, this is for a repository hosted in GitLab.com, not in a self-hosted GitLab server. There is no Windows Runner setup for the project.如何使用PowerShell脚本直接从GitLab到Azure设置持续部署?运行安装脚本后,随后对GitLab存储库的每个后续提交/合并都应自动部署到Azure.最好,此PowerShell脚本应使用AzureRM模块,但我愿意接受使用PowerShell Core和新的Az模块(基于Azure CLI)的解决方案.我正在使用的特定测试库是公共的( https://gitlab.com/MagicAndi/geekscode.net ),但这不是解决方案与私有存储库一起使用的具体要求(但如果可以,甚至更好!).How can I use a PowerShell script to setup a Continuous Deployment directly from GitLab to Azure? Once the setup script is run, each subsequent commit/merge to the GitLab repository should then automatically be deployed to Azure. Preferably, this PowerShell script should use the AzureRM modules, but I'm willing to accept a solution that uses PowerShell Core and the new Az module (based on the Azure CLI). The specific test repository I'm using is public (https://gitlab.com/MagicAndi/geekscode.net), but it isn't a specific requirement for the solution to work with private repositories (but if it does, even better!). 更新17/12/2018 我已将奖励授予 the-fish ,因为他的回答最能满足我的特定需求.但是,鉴于不赞成使用Windows Powershell和Azure RM模块,而使用PowerShell Core和新的Az模块(使用Azure CLI),我创建了新问题具体要求使用Azure CLI和Powershell的规范答案核.我计划在两天内向我开放此问题的悬赏计划.谢谢.I've awarded the bounty to the-fish as his answer best met my specific needs. However, given that Windows Powershell and the Azure RM module are being deprecated in favour of PowerShell Core and the new Az module (using the Azure CLI), I've created a new question asking specificially for a canonical answer using the Azure CLI and Powershell Core. I plan on offering a bounty for this question when it is open to me in 2 days. Thanks.推荐答案假设存储库是公共的,则可以使用以下代码:Assuming the repository is public you could use the following:$gitrepo="<replace-with-URL-of-your-own-repo>"$webappname="mywebapp$(Get-Random)"$location="West Europe"# Create a resource group.New-AzureRmResourceGroup -Name myResourceGroup -Location $location# Create an App Service plan in Free tier.New-AzureRmAppServicePlan -Name $webappname -Location $location ` -ResourceGroupName myResourceGroup -Tier Free# Create a web app.New-AzureRmWebApp -Name $webappname -Location $location -AppServicePlan $webappname ` -ResourceGroupName myResourceGroup# Configure deployment from your repo and deploy once.$PropertiesObject = @{ repoUrl = "$gitrepo"; branch = "master"; isManualIntegration = $true}Set-AzureRmResource -PropertyObject $PropertiesObject -ResourceGroupName myResourceGroup ` -ResourceType Microsoft.Web/sites/sourcecontrols -ResourceName $webappname/web ` -ApiVersion 2018-02-01 -Force让我知道它是否为私有,这可能会更加困难.如果您查看CLI源代码,则可以看到它们当前仅支持GitHub上的访问令牌.Let me know if it's private, that may be more difficult. If you look at the CLI source you can see they currently only support access tokens with GitHub. https://github.com/Azure/azure-cli/blob/4f87cb0d322c60ecc6449022467bd580a0accd57/src/command_modules/azure-cli-appservice/azure/cli/command_modules/appservice/custom.py#L964 -L1027 这篇关于使用PowerShell将代码从GitLab存储库部署到Azure Web App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-28 03:21