【问题标题】:How to use deployment slots of app services with Github Source code如何在 Github 源码中使用应用服务的部署槽
【发布时间】:2018-06-25 15:22:30
【问题描述】:

我正在从 Github 部署我的应用程序,并且我有三个不同的部署槽(Dev/Staging/prod),并且希望仅将代码部署到 Dev 并将部署的代码交换到其余阶段。

只是我还没有任何管道工具,所以想用命令行或 GUI 选项来理解,因为它是概念证明。

【问题讨论】:

    标签: azure azure-app-service-envrmnt


    【解决方案1】:

    您可以使用 Azure CLI 或 powershell 来访问它。

    Azure CLI:

    # Replace the following URL with a public GitHub repo URL
    gitrepo=https://github.com/Azure-Samples/php-docs-hello-world
    webappname=mywebapp$RANDOM
    
    # Deploy code from a public GitHub repository. 
    az webapp deployment source config --name $webappname --resource-group myResourceGroup \
    --repo-url $gitrepo --branch master --manual-integration
    

    Azure Powershell:

    # Replace the following URL with a public GitHub repo URL
    $gitrepo="https://github.com/Azure-Samples/app-service-web-dotnet-get-started.git"
    $webappname="mywebapp$(Get-Random)"
    $location="West Europe"
    
    # Configure GitHub deployment from your GitHub 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 2015-08-01 -Force
    

    发布到 azure 后,您可以swap the slot via the portal,也可以是 azure PowershellCLI

    【讨论】:

    • 谢谢@joywang。我使用上面的脚本将 Deployment slot 设置为 Prod environment 。因此,每当我签入代码时,它都会部署到 Prod 。我需要一种将代码部署到 Dev slot 的方法。我可以通过从 Prod 和 staging 中删除部署槽来在 UI 中执行此操作。 CLI 有什么办法吗?或者我也不确定这是否是一种更好的方法。
    • @satish 只需在命令中指定 webappname 和你的 Dev slot 名称,slot 就像与 web 应用程序的副本一样,该命令对部署 slot 也有效。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    • 2019-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多