{"id":3372,"date":"2023-08-25T10:32:26","date_gmt":"2023-08-25T15:32:26","guid":{"rendered":"https:\/\/microsoftgeek.com\/?p=3372"},"modified":"2023-08-25T10:32:26","modified_gmt":"2023-08-25T15:32:26","slug":"using-managed-system-identities-to-access-azure-key-vault","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=3372","title":{"rendered":"Using Managed (System) Identities to access Azure Key Vault"},"content":{"rendered":"\n<p>A common challenge that integrators run into is managing secrets and subsequently, managing access to secrets. Azure Key Vault is a service that developers can use to store their secrets, keys and other sensitive data. However, there is still a challenge with accessing these secrets. If you are storing the credentials to access Key Vault in a non-secure manner, you have just pushed the problem to another area.<\/p>\n\n\n\n<p>The good news is that we can use a capability called Managed Identities to establish trust between some Azure services. For example, we can have a Logic App that can have a Managed Identity associated with it which can then be added to Azure Key Vault RBAC roles. This establishes trust between our Logic App and Azure Key Vault.<\/p>\n\n\n\n<p>Let\u2019s now explore how we can get this setup.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Click on&nbsp;<strong>Identity<\/strong>&nbsp;as part of your Logic App settings, subsequently turn the&nbsp;<strong>Status<\/strong>&nbsp;to&nbsp;<strong>On<\/strong>. After this is completed, you will see an Object ID populated which is essentially creating an identity for your Logic App within Azure AD. Copy this value, it will allow us to assign permissions to our Logic App in a subsequent step.<\/li>\n<\/ol>\n\n\n\n<p>Click on&nbsp;<strong>Azure role assignments<\/strong>&nbsp;to continue.<br><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/1-Identity.png\" alt=\"1-Identity\"><\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"2\">\n<li>Click on&nbsp;<strong>Add role assignment<\/strong>&nbsp;followed by selecting the appropriate&nbsp;<strong>Subscription<\/strong>. From there select the appropriate&nbsp;<strong>Scope, Subscription, Resource<\/strong>&nbsp;(your keyvault instance) and the appropriate&nbsp;<strong>Role<\/strong>. In this case we will select&nbsp;<strong>Key Vault Secrets User<\/strong>&nbsp;which will allow us to extract secrets contents but not modify.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/2-role%281%29.png\" alt=\"2-role(1)\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"3\">\n<li>Repeat this step to include&nbsp;<strong>Key Vault Reader<\/strong><\/li>\n\n\n\n<li>After we click&nbsp;<strong>Save<\/strong>&nbsp;we should see the result.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/3-result%284%29.png\" alt=\"3-result(4)\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"5\">\n<li>Next up, we need to assign an Access Policy on our Key Vault instance and assign access to the Managed Identity that we just created. Find your Key Vault in Azure Portal. Click on&nbsp;<strong>Access policies<\/strong>&nbsp;and then&nbsp;<strong>Add Access Policy<\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/3b-AccessPolicy.png\" alt=\"3b-AccessPolicy\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"6\">\n<li>We can use the&nbsp;<strong>Secret Management<\/strong>&nbsp;template to help accelerate completing this task. When it comes to&nbsp;<strong>Secret permissions<\/strong>, we will reduce all access to just&nbsp;<strong>Get<\/strong>&nbsp;and&nbsp;<strong>List<\/strong>. Lastly, we will find our Managed Service principal that we created in step 1. Click&nbsp;<strong>Add<\/strong>&nbsp;and&nbsp;<strong>Save<\/strong>&nbsp;to continue.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/3c-AddPolicy.png\" alt=\"3c-AddPolicy\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"7\">\n<li>We can now edit our Logic App and add an Azure Key Vault action to our canvas. Instead of signing in with our credentials, we will click on&nbsp;<strong>Connect with managed identity<\/strong>.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/4-connect.png\" alt=\"4-connect\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"8\">\n<li>Specify a&nbsp;<strong>Connection name<\/strong>&nbsp;of your choosing and type in the name of your&nbsp;<strong>Vault<\/strong>. Click&nbsp;<strong>Create<\/strong>&nbsp;to continue.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/5-VaultName.png\" alt=\"5-VaultName\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"9\">\n<li>Select&nbsp;<strong>Name of the secret<\/strong>&nbsp;to match the secret that you want to extract.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/5b-secretname.png\" alt=\"5b-secretname\"\/><\/figure>\n\n\n\n<ol class=\"wp-block-list\" start=\"10\">\n<li>We can now add a&nbsp;<strong>Compose<\/strong>&nbsp;action where we can write out the Azure Key Vault secret value to ensure our process works.<\/li>\n<\/ol>\n\n\n\n<p><strong>Note:<\/strong>&nbsp;Whenever using sensitive information in Logic Apps, ensure that you use the&nbsp;<strong>Secure Inputs\/Outputs<\/strong>&nbsp;feature to avoid secrets leaking into your run history.<br><img decoding=\"async\" src=\"https:\/\/cdn.document360.io\/d9568273-28c0-486c-8750-64643e7f5f97\/Images\/Documentation\/6-testing%281%29.png\" alt=\"6-testing(1)\"><\/p>\n\n\n\n<ol class=\"wp-block-list\" start=\"11\">\n<li>Test your Logic App to ensure your secret is obtained successfully.<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"conclusion\">Conclusion<\/h2>\n\n\n\n<p>In this post, we discussed how we can use Managed System identities when accessing Azure services like Key Vault. This allows organizations to securely connect to Azure resources without there being a tie to an individual\u2019s credentials\/account.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A common challenge that integrators run into is managing secrets and subsequently, managing access to secrets. Azure Key Vault is a service that developers can use to store their secrets, keys and other sensitive data. However, there is still a challenge with accessing these secrets. If you are storing the credentials to access Key Vault [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69,35],"tags":[],"class_list":["post-3372","post","type-post","status-publish","format-standard","hentry","category-azure","category-cloud-computing"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3372"}],"version-history":[{"count":1,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3372\/revisions"}],"predecessor-version":[{"id":3373,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/3372\/revisions\/3373"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}