如何使用 REST API 或 ARM 模板在具有私有 GitHub 存储库的应用服务中部署应用?

问题描述

以下是我用来创建应用服务并使用私有 GitHub 存储库部署应用程序的 ARM 模板,但应用程序部署失败。

{
               "properties": {
               "mode": "Incremental","template":{
                "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#","contentVersion": "1.0.0.1","parameters": {
                    "siteName": {
                        "type": "string","defaultValue": "[concat(\'WebApp-\',uniqueString(resourceGroup().id))]","metadata": {
                            "description": "The name of you Web Site."
                        }
                    },"location": {
                        "type": "string","defaultValue": "[resourceGroup().location]","metadata": {
                            "description": "Location for all resources."
                        }
                    },"sku": {
                        "type": "string","allowedValues": [
                            "F1","D1","B1","B2","B3","S1","S2","S3","P1","P2","P3","P4"
                        ],"defaultValue": "F1","metadata": {
                            "description": "The pricing tier for the hosting plan."
                        }
                    },"workerSize": {
                        "type": "string","allowedValues": [
                            "0","1","2"
                        ],"defaultValue": "0","metadata": {
                            "description": "The instance size of the hosting plan (small,medium,or large)."
                        }
                    },"repoURL": {
                        "type": "string","defaultValue": "https://github.com/Azure-Samples/app-service-web-html-get-started.git","metadata": {
                            "description": "The URL for the GitHub repository that contains the project to deploy."
                        }
                    },"branch": {
                        "type": "string","defaultValue": "master","metadata": {
                            "description": "The branch of the GitHub repository to use."
                        }
                    }
                },"variables": {
                    "hostingPlanName": "jhyhfgljgljuhg-Plan"
                },"resources": [
                    {
                        "type": "Microsoft.Web/serverfarms","apiVersion": "2020-06-01","name": "[variables(\'hostingPlanName\')]","location": "[parameters(\'location\')]","sku": {
                            "name": "[parameters(\'sku\')]","capacity": "[parameters(\'workerSize\')]"
                        },"properties": {
                            "name": "[variables(\'hostingPlanName\')]"
                        }
                    },{
                        "type": "Microsoft.Web/sites","name": "[parameters(\'siteName\')]","identity": {
                            "type": "SystemAssigned"
                      },"dependsOn": [
                            "[resourceId(\'Microsoft.Web/serverfarms\',variables(\'hostingPlanName\'))]"
                        ],"properties": {
                            "serverFarmId": "[variables(\'hostingPlanName\')]"
                        },"resources": [
                            {
                                "type": "sourcecontrols","name": "web","dependsOn": [
                                    "[resourceId(\'Microsoft.Web/sites\',parameters(\'siteName\'))]"
                                ],"properties": {
                                    "repoUrl": "[parameters(\'repoURL\')]","branch": "[parameters(\'branch\')]","isManualIntegration": true,"ScmType":"Git"
                                }
                            }
                        ]
                    }
                ]
            },"parameters": {
                 "siteName": {
                   "value":"trouble1appservice"
               },"repoUrl": {
                "value":"https://trouble1fake:8f0276be40aaed284ac8862d198fb1e1a17f727f@github.com/trouble1fake/uploadfile"
             },"sku": {
              "value": "B1"
            },"workerSize": {
              "value": "0"
            },"branch": {
              "value": "master"
            }
                    }
                }
            }
        }

我使用的 repoUrl 是 https://trouble1fake:8f0276be40aaed284ac8862d198fb1e1a17f727f@github.com/trouble1fake/uploadfile

还是不行。 或者有什么方法可以使用rest api执行命令或导入文件?

解决方法

这不是它的工作方式。您必须先创建 GitHub 解决方案的工件,然后再部署它(无论是本地还是管道)。请参考以下方法并选择您想要的方法:

  1. 您可以使用 Visual Studio 部署您的应用程序,一旦它从您的私有存储库克隆到您的本地:Deploy an ASP.NET Web App in Azure App Service

  2. 您可以使用 Azure DevOps 管道部署您的应用程序,您可以在其中将代码添加到 ADO 服务器中并按照分步流程部署应用程序:Deploying into Azure App Service using Azure DevOps CI/CD Pipeline强>.

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...