2

I'm automating the deployment of an Azure Web App via powershell. I can't figure out how you force "HTTPS Only" to on. The code below is my best guess, but it isn't working. Any ideas?

$properties = @{"httpsOnly" = $true}
Set-AzureRmResource -PropertyObject $properties -ResourceGroupName 
$resourcegroupname  -ResourceType Microsoft.Web/sites/config -ResourceName 
$webappname/web -ApiVersion 2015-08-01 -Force
1
  • Hmm, that ApiVersion is a bit vintage, did you try with 2016-08-01? I'd also pass -Debug to see the request that gets sent on the wire. Commented Feb 12, 2018 at 17:44

1 Answer 1

2

You could use the following script.

$app=Get-AzureRmResource -ResourceId "/subscriptions/<subscription id>/resourceGroups/shuiapp/providers/Microsoft.Web/sites/shuicli"
$app.Properties.httpsOnly=$true
$app|Set-AzureRmResource -Force

Note: If you want to set httpsOnly on, the web app's App Service plan must be a paid tier (Shared, Basic, Standard, or Premium). More information about this please check this link.

I also test in Visual Studio, it also works for me.

enter image description here

I suggest you could upgrade your Azure Power Shell version.

Sign up to request clarification or add additional context in comments.

4 Comments

For a know issue on Github, after you execute the script, you need refresh your browser, then you could see this change.
Hello, thanks for the reply. I'm getting the following error: [ERROR] The property 'httpsOnly' cannot be found on this object. Verify that the [ERROR] property exists and can be set. Note, I am executing this from visualstudio.
@B.Tullero It seems you use a older version Power Shell, I suggest you could upgrade it. See this link github.com/Azure/azure-powershell/releases
@B.Tullero I also test in Visual Studio, it also works for me. What version you use? Get-Module -ListAvailable -Name Azure -Refresh to get the version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.