Deploy Code from GitLab Repository to Azure Web App using PowerShell

前端 未结 3 490
栀梦
栀梦 2021-01-04 01:15

I would like to setup continuous deployment from a GitLab repository to an Azure App using a PowerShell script. I\'m aware that you can do this manually as per:

http

3条回答
  •  -上瘾入骨i
    2021-01-04 01:33

    Assuming the repository is public you could use the following:

    $gitrepo=""
    $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
    

    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

提交回复
热议问题