Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set "Https only" for my Azure web app using an ARM template?

I know how to set Https only manually in the Azure portal. Navigating to My Web Application > Custom domains in the Azure portal opens the Custom domains pane, which has an "Https Only" option. Setting this option to "On" enables the functionality I am looking for. I found how to do this manually on Benjamin Perkins Blog. Unfortunately, it does not contain a description of how to solve the problem in an automated way using ARM templates.

How can I set this "Https only" flag in my ARM template so that I can automate this setting in my deployment? Assume I have a working ARM deployment already, and just need to know where and what to add to the template specifically for this setting.

I would like to keep answers to an ARM template based approach.

Thanks for your time!

like image 400
James Comstock Avatar asked Mar 23 '18 08:03

James Comstock


People also ask

How to enable HTTPS Azure function App?

In the Azure portal, go to your function app. Platform features > Custom Domains > toggle HTTPS Only to 'On'.

Which of the following elements are mandatory in an Azure resource manager arm template?

Azure Resource Manager (ARM) Templates It will contain five main sections: schema, parameters, variables, resources, and outputs. ContentVersion: It is a mandatory item.

What is the name of the default Azure App Service Deployment slot?

The magic of deployment slots: we can do swapping with zero downtime which means, end users will notice nothing and experience no downtime. Yes, users will experience no downtime. Therefore, this is one of the awesome features of Azure app services. Default app instance is always mapped to the production slot.


1 Answers

Yes, it is possible. You could check this link. httpsOnly is a value in properties. For example:

{
    "apiVersion": "2015-08-01",
    "name": "[parameters('webSiteName')]",
    "type": "Microsoft.Web/sites",
    "location": "[resourceGroup().location]",
    "tags": {
        "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "Resource",
        "displayName": "Website"
    },
    "dependsOn": [
        "[concat('Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]"
    ],
    "properties": {
        "name": "[parameters('webSiteName')]",
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('hostingPlanName'))]",
        "httpsOnly": true
    }
}

ps. Template reference might contain error, use api reference (its not perfect, but its better).

like image 105
Shui shengbao Avatar answered Oct 27 '22 20:10

Shui shengbao