简体   繁体   中英

Re-deploy Azure Web App Service and Plan using ARM Templates

I'm new to Azure and newer to using ARM templates.

I've got an App Service and Service Plan supporting Windows OS that needs to be changed to Linux. From what I can tell, there is no direct modification to achieve this result, I'm going to need to delete and redeploy.

I was looking at steps for manual deletion and re-build, but I'm thinking that using ARM templates would likely be more effective. I'm researching using ARM templates but not getting much information about using them for removal/modify/replacement. I'd guess that I can download the existing ARM templates and re-deploy, but there have to be a handful of gotchas, but I don't know what to look for.

My expectation is that the ARM template would not be able to deploy the custom domain and its certificate ready to go. Also, the existing template has references to snapshots that would likely be gone after deletion, so I'd expect to have to remove those references from the template prior to re-deploy.

Any guidance I can get would be greatly appreciated

Per

One of the workaround you can follow;

I'm researching using ARM templates but not getting much information about using them for removal/modify/replacement

AFAIK, There is no direct command to delete the resources through which are deployed to Azure using ARM.

Instead of that you can use Azure cli as suggested in this SO THREAD ,

Because after deployment there is still you can see in the deployment logs your resource are there you can delete from the portal itself.

在此处输入图像描述

After remove the app service from portal you can redeploy the same with adding your modifications .

We have tried after deploy the application and then remove/delete from portal as mentioned above and then re-deploy the app service with linux environment and its work fine.

You can make it use of below template(eg):- template.json

{
                              "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
                              "contentVersion": "1.0.0.0",
                              "parameters": {
                                "webAppName": {
                                  "type": "string",
                                  "defaultValue": "AzureLinuxApp",
                                  "metadata": {
                                    "description": "Base name of the resource such as web app name and app service plan "
                                  },
                                  "minLength": 2
                                },
                                "sku": {
                                  "type": "string",
                                  "defaultValue": "S1",
                                  "metadata": {
                                    "description": "The SKU of App Service Plan "
                                  }
                                },
                                "linuxFxVersion": {
                                  "type": "string",
                                  "defaultValue": "php|7.4",
                                  "metadata": {
                                    "description": "The Runtime stack of current web app"
                                  }
                                },
                                "location": {
                                  "type": "string",
                                  "defaultValue": "[resourceGroup().location]",
                                  "metadata": {
                                    "description": "Location for all resources."
                                  }
                                }
                              },
                              "variables": {
                                "webAppPortalName": "[concat(parameters('webAppName'), '-webapp')]",
                                "appServicePlanName": "[concat('AppServicePlan-', parameters('webAppName'))]"
                              },
                              "resources": [
                                {
                                  "type": "Microsoft.Web/serverfarms",
                                  "apiVersion": "2020-06-01",
                                  "name": "[variables('appServicePlanName')]",
                                  "location": "[parameters('location')]",
                                  "sku": {
                                    "name": "[parameters('sku')]"
                                  },
                                  "kind": "linux",
                                  "properties": {
                                    "reserved": true
                                  }
                                },
                                {
                                  "type": "Microsoft.Web/sites",
                                  "apiVersion": "2020-06-01",
                                  "name": "[variables('webAppPortalName')]",
                                  "location": "[parameters('location')]",
                                  "kind": "app",
                                  "dependsOn": [
                                    "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]"
                                  ],
                                  "properties": {
                                    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('appServicePlanName'))]",
                                    "siteConfig": {
                                      "linuxFxVersion": "[parameters('linuxFxVersion')]"
                                    }
                                  }
                                }
                              ]
                            }

app.parameter.json

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": { 
"webAppName": {
"value": "mylinuxappp"
}
}
}

OUTPUT DETAILS FOR REFERENCE:-

在此处输入图像描述 在此处输入图像描述

在此处输入图像描述 在此处输入图像描述

To deploy webapp with custom domain and ssl certificate need to make sure that its already verified and also need to use existing keyvault for the SSL binding . Please find this arm template for more information .

Please refer the below links for get started with Azure App service using arm template with different scenarios(step by step guidance). It should be help more to understand .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM