如何使用 REST API 或 ARM 模板在具有私有 GitHub 存储库的应用程序服务中部署应用程序?
How Can I deploy Apps in app service with private GitHub repository using REST API or ARM templates?
以下是我用来创建应用程序服务并使用私有 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",
"apiVersion": "2020-06-01",
"name": "[parameters(\'siteName\')]",
"location": "[parameters(\'location\')]",
"identity": {
"type": "SystemAssigned"
},
"dependsOn": [
"[resourceId(\'Microsoft.Web/serverfarms\', variables(\'hostingPlanName\'))]"
],
"properties": {
"serverFarmId": "[variables(\'hostingPlanName\')]"
},
"resources": [
{
"type": "sourcecontrols",
"apiVersion": "2020-06-01",
"name": "web",
"location": "[parameters(\'location\')]",
"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 解决方案的工件,然后再部署它(本地或管道)。请参考以下方法并选择您想要的方法:
您可以使用 Visual Studio
部署您的应用程序,一旦它从您的私有存储库克隆到本地:Deploy an ASP.NET Web App in Azure App Service
您可以使用 Azure DevOps 管道部署您的应用程序,其中您可以在 ADO 服务器中添加代码并按照分步过程部署应用程序:Deploying into Azure App Service using Azure DevOps CI/CD Pipeline.
以下是我用来创建应用程序服务并使用私有 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",
"apiVersion": "2020-06-01",
"name": "[parameters(\'siteName\')]",
"location": "[parameters(\'location\')]",
"identity": {
"type": "SystemAssigned"
},
"dependsOn": [
"[resourceId(\'Microsoft.Web/serverfarms\', variables(\'hostingPlanName\'))]"
],
"properties": {
"serverFarmId": "[variables(\'hostingPlanName\')]"
},
"resources": [
{
"type": "sourcecontrols",
"apiVersion": "2020-06-01",
"name": "web",
"location": "[parameters(\'location\')]",
"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 解决方案的工件,然后再部署它(本地或管道)。请参考以下方法并选择您想要的方法:
您可以使用
Visual Studio
部署您的应用程序,一旦它从您的私有存储库克隆到本地:Deploy an ASP.NET Web App in Azure App Service您可以使用 Azure DevOps 管道部署您的应用程序,其中您可以在 ADO 服务器中添加代码并按照分步过程部署应用程序:Deploying into Azure App Service using Azure DevOps CI/CD Pipeline.