News brief3 Dec 2026 · Chrome will stop trusting P-256 CA keys on 15 March 2027Read the summary
CipherNexus

← Insights

Field note

Binding a renewed certificate to an Azure Web App when the CLI crashes

A field note on az webapp config ssl bind failing with a NoneType error during automated renewal, and the REST API fallback that fixed it.

We automate certificate renewal for an Azure Web App with a PowerShell post-script: a renewal produces a new PFX, the script uploads it, and the custom domain is bound to the new certificate. The upload worked. The bind did not.

The symptom

az webapp config ssl bind exited with code 1 and this traceback ending:

File ".../azure/cli/command_modules/appservice/custom.py", line 7585, in _update_ssl_binding
TypeError: object of type 'NoneType' has no len()

This was Azure CLI 2.90.0. The certificate had uploaded successfully and listed the right host name, so a missing host name list was not the cause. The only unusual thing about the site was that the custom domain already had an older certificate bound to it.

We have not established the root cause inside the CLI. Treat the explanation below as a workaround, not a diagnosis.

The workaround

The hostname binding itself can be set directly through the Azure Resource Manager API. The script now tries the normal CLI command first, and if that fails it calls the REST endpoint for the specific custom domain:

$uri = "https://management.azure.com/subscriptions/$subscriptionId" +
       "/resourceGroups/$resourceGroup/providers/Microsoft.Web/sites/$webApp" +
       "/hostNameBindings/$customDomain?api-version=2022-09-01"

$body = @{ properties = @{
    siteName                    = $webApp
    hostNameType                = "Verified"
    customHostNameDnsRecordType = "CName"
    sslState                    = "SniEnabled"
    thumbprint                  = $thumbprint
}} | ConvertTo-Json -Depth 4 -Compress

Set-Content -Path $bodyFile -Value $body -Encoding ASCII
az rest --method put --uri $uri --body "@$bodyFile"

Writing the body to a file avoids PowerShell and az.cmd quoting problems with JSON.

Do not trust the exit code alone

After the bind, the script reads the hostname bindings back and compares the thumbprint:

az webapp config hostname list --resource-group $resourceGroup `
   --webapp-name $webApp --query "[?name=='$customDomain'].thumbprint | [0]" -o tsv

If the thumbprint on the custom domain is not the new one, the run is reported as failed. The old check looked at the certificate object's host names, which only reflect the CN and SAN values and do not prove the site is serving that certificate.

Other things that tripped us up

  • Permissions. Uploading a certificate writes to the App Service Plan, so Website Contributor on the web app is not enough. You need write access on the plan as well. We used a narrow custom role rather than granting full Contributor.
  • HTTPS-only policy. Some Azure Policy initiatives deny writes to a web app while httpsOnly is false, and ssl bind is such a write. Set HTTPS-only before the bind.
  • SNI, not IP-based SSL. For a normal custom domain, choose SNI SSL. IP-based SSL costs extra and is only needed for very old clients.
  • Short certificate lifetimes. The certificate in this setup is valid for 30 days, so the renewal and bind path is exercised every month. It is worth making it boring.

If you have a certificate renewal workflow that stops at the last step, a read-back verification like the one above is the single most useful thing to add.

AzureAutomationCertificate lifecycleField notes

Abdul Aziz Farooq

Founder & CTO at CipherNexus. We work on PKI, certificate automation, HSMs, digital signatures and post-quantum readiness. Talk to us about your project.

Tell us what you are working on.

A PKI build, a renewal that keeps failing, a signing platform or a post-quantum plan. We read every enquiry.

Contact us