{"id":21830,"date":"2020-03-25T13:50:53","date_gmt":"2020-03-25T13:50:53","guid":{"rendered":"https:\/\/aidanfinn.com\/?p=21830"},"modified":"2020-03-26T16:22:54","modified_gmt":"2020-03-26T16:22:54","slug":"errors-when-you-add-a-cert-to-application-gateway-listener-from-key-vault","status":"publish","type":"post","link":"https:\/\/aidanfinn.com\/?p=21830","title":{"rendered":"Errors When You Add A Cert To Application Gateway Listener From Key Vault"},"content":{"rendered":"<p>This post is dealing with a situation where you attempt to add a certificate to a v2 Azure Application Gateway\/Firewall (WAG_v2\/WAF_v2) from an Azure Key Vault. The attempt fails and any further attempt to delete\/modify the certificate fails with this error:<\/p>\n<blockquote><p>Invalid value for the identities &#8216;\/subscriptions\/xxxxxxx\/resourcegroups\/myapp\/providers\/Microsoft.ManagedIdentity\/userAssignedIdentities\/myapp-waf-id&#8217;. The &#8216;UserAssignedIdentities&#8217; property keys should only be empty json objects, null or the resource exisiting property.<\/p><\/blockquote>\n<h2>Application Gateway v2 and Key Vault<\/h2>\n<p>Azure Key Vault is the best place to store secrets in Microsoft Azure &#8211; particularly SSL certificates. Key Vault has a nice system for abstracting versions of a certificate so you can put in newer versions without changing references to the older one. There is also a feature for automatic renewal of expiring certs from certain issuers. I also like the separation of exposed resource from organisation secrets that you get with this approach; the legacy method was that you had to upload the cert into the WAG\/WAF, but now WAG_v2\/WAF_v2 allow you to store the certs in a Key Vault, and that limited access is done using a managed user ID (an Azure resource, not an Azure AD resource, which makes it more agile).<\/p>\n<h2>The Problem<\/h2>\n<p>I was actually going to write a blog post about how to obtain the secret ID of a certificate from the Key Vault so you could add it to the WAGv2\/WAFv2. But as I was setting up the lab, I realised that during the day, Microsoft had updated the Azure Portal blade so certs were instead presented as a drop-down list box; now my post was pointless. But I continued setting things up and hit the above issue.<\/p>\n<h2>The Cause\/Fix<\/h2>\n<p>When you use this architecture, WAF_v2\/WAG_v2 requires that you have enabled soft delete on the Key Vault. And that&#8217;s the only check that they have been doing. The default setting for Key Vault soft delete is 90 days. I was in a lab, I was mucking around, so I set soft delete in my Key Vault to 7 days &#8211; a perfectly legit value for Key Vault. However, the Application Gateway (AppGW) requires it to be set to 90 days minimum &#8230; even though it does not check it!<\/p>\n<p>To undo the damage you can run the following PowerShell cmdlets:<\/p>\n<ul>\n<li>Set-AzApplicationGatewayIdentity<\/li>\n<li>Remove-AzApplicationGatewaySslCertificate<\/li>\n<li>Remove-AzApplicationGatewayHttpListener<\/li>\n<li>Set-AzApplicationGateway to update the WAF<\/li>\n<\/ul>\n<p><em>Thanks to Cat in the Azure network team for the help!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This post is dealing with a situation where you attempt to add a certificate to a v2 Azure Application Gateway\/Firewall (WAG_v2\/WAF_v2) from an Azure Key Vault. The attempt fails and any further attempt to delete\/modify the certificate fails with this error: Invalid value for the identities &#8216;\/subscriptions\/xxxxxxx\/resourcegroups\/myapp\/providers\/Microsoft.ManagedIdentity\/userAssignedIdentities\/myapp-waf-id&#8217;. The &#8216;UserAssignedIdentities&#8217; property keys should only be empty &hellip; <a href=\"https:\/\/aidanfinn.com\/?p=21830\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Errors When You Add A Cert To Application Gateway Listener From Key Vault&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[5],"tags":[316,314,170,428,411,427,340,342],"class_list":["post-21830","post","type-post","status-publish","format-standard","hentry","category-azure","tag-application-firewall","tag-application-gateway","tag-azure","tag-certificate","tag-key-vault","tag-ssl","tag-wafv2","tag-wagv2"],"aioseo_notices":[],"jetpack_featured_media_url":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/21830","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=21830"}],"version-history":[{"count":8,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/21830\/revisions"}],"predecessor-version":[{"id":21838,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/21830\/revisions\/21838"}],"wp:attachment":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=21830"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=21830"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=21830"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}