<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Azure HowTo - TheCodeBuzz</title>
	<atom:link href="https://thecodebuzz.com/category/azure-howto/feed/" rel="self" type="application/rss+xml" />
	<link>https://thecodebuzz.com</link>
	<description>Best Practices for Software Development</description>
	<lastBuildDate>Tue, 20 Oct 2026 16:51:23 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://thecodebuzz.com/wp-content/uploads/2022/11/cropped-android-chrome-512x512-1-1-51x51.jpg</url>
	<title>Azure HowTo - TheCodeBuzz</title>
	<link>https://thecodebuzz.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Copy Docker Container Images to Azure Private Registry</title>
		<link>https://thecodebuzz.com/copy-docker-container-image-to-azure-private-registry/</link>
					<comments>https://thecodebuzz.com/copy-docker-container-image-to-azure-private-registry/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 14 Aug 2022 17:41:00 +0000</pubDate>
				<category><![CDATA[Azure HowTo]]></category>
		<category><![CDATA[Container]]></category>
		<category><![CDATA[Copy Docker Container to Azure]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=21661</guid>

					<description><![CDATA[<p>Copy Docker Container Images to Azure Private Registry Today in this article, we will see how to Import or copy Docker Container Images to Azure Private Registry using step by step guide. Here you can use simple Azure CLI or Power CLI commands to copy or import ready images from a public registry like DockerHub. [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/copy-docker-container-image-to-azure-private-registry/">Copy Docker Container Images to Azure Private Registry</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Copy Docker Container Images to Azure Private Registry</h1>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="478" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-1024x478.jpg" alt="" class="wp-image-21683" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-1024x478.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-300x140.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-768x359.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-1536x718.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-2048x957.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-or-import-Docker-Container-Image-to-Azure-Private-Registry-785x367.jpg 785w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph">Today in this article, we will see how to Import or copy Docker Container Images to Azure Private Registry using step by step guide.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Here you can use simple Azure CLI or Power CLI commands to copy or import ready images from a public registry like DockerHub.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">We will see below how to import the Docker Images from DockerHub without using any docker commands.</p>



<p class="wp-block-paragraph"></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-getting-started---import-from-docker-hub">Getting started &#8211; Import from Docker Hub</a></li><li><a href="#aioseo-step-1--create-azure-container-registry">Step 1- Create Azure  container registry</a></li><li><a href="#aioseo-step-2--import-image-from-docker-hub">Step 2- Import Image from Docker Hub</a></li><li><a href="#aioseo-verify-or-list-container-images-from-azure-registry">Verify or List container images from Azure Registry</a></li></ul></div>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-getting-started---import-from-docker-hub">Getting started &#8211; Import from Docker Hub</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please login to the Azure Cloud subscription account and have a resource group ready so as to use this feature.</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-step-1--create-azure-container-registry">Step 1- Create Azure  container registry </h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">If you already have ACR created you can skip this step.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s use the below steps to create an Azure Container registry.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr create --resource-group myResourceGroup
--name myRegistry --sku Basic</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr create --resource-group thecodebuzz-group --name TheCodeBuzzRegistry --sku basic</pre>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-step-2--import-image-from-docker-hub">Step 2- Import Image from Docker Hub</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">I have the below images in the remote Docker hub.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-full is-resized"><img decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Private-Registry-azure-cli.jpg" alt="Copy Docker Container Image to Azure Private Registry " class="wp-image-21680" width="437" height="395" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Private-Registry-azure-cli.jpg 719w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Private-Registry-azure-cli-300x271.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Private-Registry-azure-cli-575x520.jpg 575w" sizes="(max-width: 437px) 100vw, 437px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr import  --name myRegistry 
--source docker.io/&lt;repo-name&gt;/&lt;image-name&gt;:&lt;tag-name&gt; --image &lt;image-name&gt;:&lt;tag-name&gt;


</pre>



<p class="wp-block-paragraph">OR</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">If You need to use a Docker username and password for authentication,</p>



<p class="wp-block-paragraph"> </p>



<pre id="block-cbcb70c1-9609-4293-9b4b-4927e0de512a" class="wp-block-preformatted has-medium-font-size">az acr import  --name myRegistry <br>--source docker.io/&lt;repo-name&gt;/&lt;image-name&gt;:&lt;tag-name&gt; --image &lt;image-name&gt;:&lt;tag-name&gt; --username &lt;username&gt; --password &lt;password&gt;</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph" id="block-cbcb70c1-9609-4293-9b4b-4927e0de512a"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr import --name TheCodeBuzzRegistry --source docker.io/firstthecodebuzz/forazureacr:v1 --image forazureacr:v1 --username firstthecodebuzz --password *****



 </pre>



<p class="wp-block-paragraph">Once executed you shall be able to import the image into the Azure private registry. Please wait some time to get the import finished successfully.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="75" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-1024x75.jpg" alt="" class="wp-image-21681" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-1024x75.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-300x22.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-768x56.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-1536x112.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-2048x150.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2022/04/Import-Docker-Container-Image-to-Azure-Private-Registry-azure-cli-785x57.jpg 785w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-verify-or-list-container-images-from-azure-registry">Verify or List container images from Azure Registry</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please use the below command to list and verify available images in the Azure registry,</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr repository list --name myRegistryName --output table</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr repository list --name thecodebuzzregistry --output table</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">OR</p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az acr repository list --name thecodebuzzregistry.azurecr.io --output table</pre>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="209" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-1024x209.jpg" alt="Copy Docker Container Image to Azure Private Registry " class="wp-image-21682" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-1024x209.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-300x61.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-768x156.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-1536x313.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-2048x417.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2022/04/Copy-Docker-Container-Image-to-Azure-Private-Registry-using-azure-cli-785x160.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Finally, you shall see that your docker image was successfully imported from the docker hub to the Azure private registry.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>References</em></strong>:  </p>



<ul class="wp-block-list">
<li><a href="https://www.thecodebuzz.com/angular-app-dockerize-containerize-using-ngnix/" target="_blank" rel="noreferrer noopener"><em><strong>Docker- Containerize an Angular App with NGNIX</strong></em></a></li>
</ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size wp-block-paragraph"></p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Happy Coding </strong>!!</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<hr>



<p class="wp-block-paragraph"></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p><p>The post <a href="https://thecodebuzz.com/copy-docker-container-image-to-azure-private-registry/">Copy Docker Container Images to Azure Private Registry</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/copy-docker-container-image-to-azure-private-registry/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Azure &#8211; Get All Pull requests using ADO DevOps API</title>
		<link>https://thecodebuzz.com/azure-ado-api-get-all-pull-requests-using-ado-devops-api/</link>
					<comments>https://thecodebuzz.com/azure-ado-api-get-all-pull-requests-using-ado-devops-api/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 04 Jul 2022 00:54:00 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Azure HowTo]]></category>
		<category><![CDATA[azure devops api approve pull request]]></category>
		<category><![CDATA[azure devops api examples]]></category>
		<category><![CDATA[azure devops api get file from repo]]></category>
		<category><![CDATA[azure devops api list git branches]]></category>
		<category><![CDATA[azure devops export pull requests]]></category>
		<category><![CDATA[azure devops organization api]]></category>
		<category><![CDATA[azure devops show all pull requests]]></category>
		<category><![CDATA[postman azure devops rest api]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=22783</guid>

					<description><![CDATA[<p>Azure &#8211; Get All Pull requests using ADO DevOps API Today in this article, we will see Azure &#8211; Get All Pull requests using ADO DevOps API feature in detail. It&#8217;s easy to call Azure DevOps API and get the pull request details. One can automate the process using the AZ command or CLI or [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/azure-ado-api-get-all-pull-requests-using-ado-devops-api/">Azure – Get All Pull requests using ADO DevOps API</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Azure &#8211; Get All Pull requests using ADO DevOps API</h1>



<figure class="wp-block-image size-full is-resized"><a href="https://www.thecodebuzz.com/trigger-azure-pipelines-build-api-for-automating-azure-devops" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/03/how-to-queue-a-new-build-using-vsts-rest-api.jpg" alt="API for automating Azure DevOps Pipelines ,trigger-azure-pipelines-build-api-for-automating-azure-devops" class="wp-image-21348" width="722" height="371" srcset="https://thecodebuzz.com/wp-content/uploads/2022/03/how-to-queue-a-new-build-using-vsts-rest-api.jpg 906w, https://thecodebuzz.com/wp-content/uploads/2022/03/how-to-queue-a-new-build-using-vsts-rest-api-300x155.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/03/how-to-queue-a-new-build-using-vsts-rest-api-768x396.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/03/how-to-queue-a-new-build-using-vsts-rest-api-785x405.jpg 785w" sizes="auto, (max-width: 722px) 100vw, 722px" /></a></figure>



<p class="wp-block-paragraph">Today in this article, we will see Azure &#8211; Get All Pull requests using ADO DevOps API feature in detail.</p>



<p class="wp-block-paragraph"></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-trigger-an-ado-build--using-queue-api">Trigger an ADO build- using Queue API</a></li><li><a href="#aioseo-configuration-and-security">Configuration and security</a></li></ul></div>



<p class="wp-block-paragraph">It&#8217;s easy to call Azure DevOps API and get the pull request details. One can automate the process using the AZ command or CLI or PowerShell script.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">We will use the below API for the same.</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-trigger-an-ado-build--using-queue-api">Trigger an ADO build- using Queue API </h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>GET API</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repo-name}/pullrequests?&amp;api-version=6.0</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Build pipeline With optional parameters</strong></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>GET API</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">https://dev.azure.com/jan2022-thecodebuzz/globalexceptionhandler/_apis/git/repositories/globalexceptionhandler/pullrequests?&amp;api-version=6.0</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">In the above Post request below are the input parameters,</p>



<p class="wp-block-paragraph"></p>



<ul class="wp-block-list"><li><strong><em>organization </em> </strong>&#8211; The name of the Azure DevOps organization.</li></ul>



<ul class="wp-block-list"><li><em><strong>project</strong>  </em>&#8211; Project ID or project name</li></ul>



<ul class="wp-block-list"><li><strong><em>api version </em></strong>&#8211; Version of the API to use. </li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Below is our sample repository,</p>



<p class="wp-block-paragraph"></p>



<p class="has-medium-font-size wp-block-paragraph"><a href="https://dev.azure.com/jan2022-thecodebuzz/globalexceptionhandler/_build">https://dev.azure.com/jan2022-thecodebuzz/globalexceptionhandler/_build</a></p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="622" src="https://www.thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api-1024x622.jpg" alt="Azure - Get All Pull requests using ADO DevOps API " class="wp-image-21341" srcset="https://thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api-1024x622.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api-300x182.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api-768x466.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api-1536x933.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api-785x477.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/03/trigger-azure-pipelines-build-via-api.jpg 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-configuration-and-security">Configuration and security </h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s now configure the API to be invoked securely.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Step1- Click on the User settings and set up the <em><strong>personal access token</strong></em>.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/03/UntitAPI-for-automating-Azure-DevOps-Pipelinesled-730x1024.jpg" alt="start-a-build-and-passing-variables-through-azure-devops-rest-api" class="wp-image-21342" width="313" height="439" srcset="https://thecodebuzz.com/wp-content/uploads/2022/03/UntitAPI-for-automating-Azure-DevOps-Pipelinesled-730x1024.jpg 730w, https://thecodebuzz.com/wp-content/uploads/2022/03/UntitAPI-for-automating-Azure-DevOps-Pipelinesled-214x300.jpg 214w, https://thecodebuzz.com/wp-content/uploads/2022/03/UntitAPI-for-automating-Azure-DevOps-Pipelinesled-371x520.jpg 371w, https://thecodebuzz.com/wp-content/uploads/2022/03/UntitAPI-for-automating-Azure-DevOps-Pipelinesled.jpg 765w" sizes="auto, (max-width: 313px) 100vw, 313px" /></figure>



<p class="wp-block-paragraph">Define a name for this token and authorize the scope of access with this token. You can choose this token access for the Build pipeline trigger or release pipeline trigger etc.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">I have below sample 2 pull request </p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="289" src="https://www.thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-API--1024x289.jpg" alt="" class="wp-image-22784" srcset="https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-API--1024x289.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-API--300x85.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-API--768x216.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-API--785x221.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-API-.jpg 1462w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Once you execute the GET API, all metadata associated with Pull request can be accessed easily ,</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="681" src="https://www.thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-powershell-1024x681.jpg" alt="" class="wp-image-22785" srcset="https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-powershell-1024x681.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-powershell-300x200.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-powershell-768x511.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-powershell-782x520.jpg 782w, https://thecodebuzz.com/wp-content/uploads/2022/07/Azure-Get-All-Pull-requests-using-ADO-DevOps-powershell.jpg 1200w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>References</strong>: </p>



<p class="wp-block-paragraph"></p>



<ul class="has-medium-font-size wp-block-list"><li><a href="https://www.thecodebuzz.com/create-https-nginx-on-linux-azure-virtual-machine-ubuntu/" target="_blank" rel="noreferrer noopener" title="Create HTTP with NGINX on Linux in Azure Virtual Machine"><em>Create HTTP with NGINX on Linux in Azure Virtual Machine</em></a></li></ul>



<p class="wp-block-paragraph"></p>



<ul class="has-medium-font-size wp-block-list"><li><a style="font-size: revert;" href="https://www.thecodebuzz.com/azure-devops-build-pipelines-using-run-pipeline-api-automate/" title="Automating Azure DevOps Build Pipelines using Run Pipeline API"><em>Automating Azure DevOps Build Pipelines using Run Pipeline API</em></a> </li></ul>



<hr>



<p class="wp-block-paragraph"></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p><p>The post <a href="https://thecodebuzz.com/azure-ado-api-get-all-pull-requests-using-ado-devops-api/">Azure – Get All Pull requests using ADO DevOps API</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/azure-ado-api-get-all-pull-requests-using-ado-devops-api/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Azure KeyVault &#8211; Create, Purge or Soft Delete or Recover secretes</title>
		<link>https://thecodebuzz.com/azure-keyvault-create-purge-or-soft-delete-or-recover-secretes/</link>
					<comments>https://thecodebuzz.com/azure-keyvault-create-purge-or-soft-delete-or-recover-secretes/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Mon, 13 Jun 2022 17:44:00 +0000</pubDate>
				<category><![CDATA[Azure HowTo]]></category>
		<category><![CDATA[allow the azure app configuration instance to use an azure key vault key]]></category>
		<category><![CDATA[az keyvault list-deleted]]></category>
		<category><![CDATA[az keyvault purge]]></category>
		<category><![CDATA[azure key vault permissions list]]></category>
		<category><![CDATA[azure key vault soft-delete vs purge protection]]></category>
		<category><![CDATA[disable purge protection key vault]]></category>
		<category><![CDATA[purge protection azure key vault]]></category>
		<category><![CDATA[the operation "purge" is not enabled in the access policy of this secret]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=21809</guid>

					<description><![CDATA[<p>AzuAzure KeyVault &#8211; Create, Purge or Soft Delete or Recover secretes Today in this article, we will go over a few basic commands for Azure KeyVault &#8211; Create, Purge or Soft Delete or Recover secretes. Using Portal to delete the Vault Secretes f you need to delete an app secrete, then you can delete the [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/azure-keyvault-create-purge-or-soft-delete-or-recover-secretes/">Azure KeyVault – Create, Purge or Soft Delete or Recover secretes</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">AzuAzure KeyVault &#8211; Create, Purge or Soft Delete or Recover secretes</h1>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="506" height="397" src="https://www.thecodebuzz.com/wp-content/uploads/2022/07/secure-api-secrets-azure-key-vault-.jpg" alt="" class="wp-image-22789" srcset="https://thecodebuzz.com/wp-content/uploads/2022/07/secure-api-secrets-azure-key-vault-.jpg 506w, https://thecodebuzz.com/wp-content/uploads/2022/07/secure-api-secrets-azure-key-vault--300x235.jpg 300w" sizes="auto, (max-width: 506px) 100vw, 506px" /></figure>



<p class="wp-block-paragraph">Today in this article, we will go over a few basic commands for Azure KeyVault &#8211; Create, Purge or Soft Delete or Recover secretes.</p>



<p class="wp-block-paragraph"></p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-using-portal-to-delete-the-vault-secretes">Using Portal to delete the Vault Secretes</a></li><li><a href="#aioseo-recover-deleted-secretes">Recover deleted secretes</a></li><li><a href="#aioseo-get-the-list-of-deleted-secretes">Get the list of deleted secretes</a></li></ul></div>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-using-portal-to-delete-the-vault-secretes">Using Portal to delete the Vault Secretes</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"> f you need to delete an app secrete, then you can delete the secretes using the below option,</p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Delete-vault-secretes-using-Azure-Portal-1024x408.jpg" alt="Azure KeyVault - Create, Purge or Soft Delete or Recover secretes" class="wp-image-21817" width="603" height="239" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Delete-vault-secretes-using-Azure-Portal-1024x408.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Delete-vault-secretes-using-Azure-Portal-300x119.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Delete-vault-secretes-using-Azure-Portal-768x306.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Delete-vault-secretes-using-Azure-Portal-785x313.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Delete-vault-secretes-using-Azure-Portal.jpg 1273w" sizes="auto, (max-width: 603px) 100vw, 603px" /></figure>



<p class="wp-block-paragraph">If you need to delete an app secrete then use the below command,</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault secret purge --name appsecret --vault-name newvault1000</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Example </p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault secret purge --name appsecret --vault-name newvault1000</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">If the deletes are enabled as soft delete , means all the secretes deleted will go into a retention period and will be retained up to <strong><em>90 days after the cut-off tim</em></strong>e.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="315" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-1024x315.jpg" alt="" class="wp-image-21815" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-1024x315.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-300x92.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-768x236.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-1536x472.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-2048x630.jpg 2048w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-retention-is-enabled-785x241.jpg 785w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-recover-deleted-secretes">Recover deleted secretes</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault secret recover --name appsecret --vault-name newvault1000</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault secret recover --name appsecret --vault-name newvault1000</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-get-the-list-of-deleted-secretes">Get the list of deleted secretes</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault secret list-deleted --vault-name newvault1000</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault secret list-deleted --vault-name thecodebuzz-key-vault
</pre>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="509" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1-1024x509.jpg" alt="" class="wp-image-21813" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1-1024x509.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1-300x149.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1-768x382.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1-1536x763.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1-785x390.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/Azure-Key-Vault-Purge-or-Soft-Delete-secretes-1.jpg 1614w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>References</em></strong> : </p>



<p class="wp-block-paragraph"></p>



<ul class="has-medium-font-size wp-block-list"><li><a href="https://www.thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/" target="_blank" rel="noreferrer noopener" title="Secure secrets using Azure KeyVault MSI with examples"><em>Secure secrets using Azure KeyVault MSI with examples</em></a></li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size wp-block-paragraph"></p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Happy Coding </strong>!!</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p><p>The post <a href="https://thecodebuzz.com/azure-keyvault-create-purge-or-soft-delete-or-recover-secretes/">Azure KeyVault – Create, Purge or Soft Delete or Recover secretes</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/azure-keyvault-create-purge-or-soft-delete-or-recover-secretes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Secure secrets using Azure KeyVault -Approach II</title>
		<link>https://thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret/</link>
					<comments>https://thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Wed, 11 May 2022 00:00:26 +0000</pubDate>
				<category><![CDATA[Azure HowTo]]></category>
		<category><![CDATA[asp.net core]]></category>
		<category><![CDATA[Azure Key Vault]]></category>
		<category><![CDATA[azure key vault best practices]]></category>
		<category><![CDATA[azure key vault get all secrets]]></category>
		<category><![CDATA[azure key vault is used to store secrets for]]></category>
		<category><![CDATA[azure key vault secret]]></category>
		<category><![CDATA[azure key vault secret content type]]></category>
		<category><![CDATA[azure key vault secret name restrictions]]></category>
		<category><![CDATA[configure access to secrets in azure key vault with]]></category>
		<category><![CDATA[DefaultAzureCredential]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=21853</guid>

					<description><![CDATA[<p>Secure secrets using Azure KeyVault -Approach II Today in this article we will see how to secure secrets using Azure KeyVault using a non-MSI approach. Updated October 2026: an RBAC permissions section, guidance on protecting the client secret and local development, and an FAQ. Today in this article, we will cover below aspects, Here we [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret/">Secure secrets using Azure KeyVault -Approach II</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading"><strong>Secure secrets using Azure KeyVault -Approach II</strong></h1>



<figure class="wp-block-image size-full"><a href="https://www.thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret" target="_blank" rel="noopener"><img loading="lazy" decoding="async" width="600" height="315" src="https://www.thecodebuzz.com/wp-content/uploads/2022/05/secure-api-secrets-azure-key-vault.jpg" alt="Secure secrets using Azure KeyVault" class="wp-image-22215" srcset="https://thecodebuzz.com/wp-content/uploads/2022/05/secure-api-secrets-azure-key-vault.jpg 600w, https://thecodebuzz.com/wp-content/uploads/2022/05/secure-api-secrets-azure-key-vault-300x158.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></figure>



<p class="wp-block-paragraph">Today in this article we will see how to secure secrets using Azure KeyVault using a non-MSI approach.</p>



<p class="tcb-update-note"><em>Updated October 2026: an RBAC permissions section, guidance on protecting the client secret and local development, and an FAQ.</em></p>




<p class="wp-block-paragraph"> Today in this article, we will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-prerequisites">Prerequisites</a></li><li><a href="#aioseo-get-value-for-azure_client_id--azure_tenant_id--azure_client_secret">Get Value for AZURE_CLIENT_ID ,  AZURE_TENANT_ID , AZURE_CLIENT_SECRET</a></li><li><a href="#aioseo-approach-2---authenticate-the-application-using-msi--managed-service-identity">Approach 2 &#8211; Authenticate the Application using MSI ( Managed Service Identity</a></li></ul></div>



<p class="wp-block-paragraph">Here we will use configuration values for the below variables declaratively, </p>



<ul class="wp-block-list"><li><em><strong>AZURE_CLIENT_ID</strong>, </em></li><li><em><strong>AZURE_TENANT_ID</strong>,</em></li><li><strong><em>AZURE_CLIENT_SECRET</em></strong>.</li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s look into step by step how to get the above-used <b><i>key vault URL</i></b> and define secretes value for <em><strong>DbPassword</strong></em>.</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-prerequisites">Prerequisites </h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Before we get started with actual Azure Vault implementation please make sure you have the below prerequisites defined already in your Azure cloud account,</p>



<p class="wp-block-paragraph"></p>



<ul class="has-normal-font-size wp-block-list"><li>Create a Resource group( if not already exist )</li><li>Create an App Service plan</li><li>Create Azure WebApp (App Service) in the App service plan</li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">For more details on the above steps, please visit this article &#8211; <a href="https://www.thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/" target="_blank" rel="noreferrer noopener" title="Secure secrets using Azure KeyVault MSI with examples"><strong>Secure secrets using Azure KeyVault MSI with examples</strong></a></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please make sure to define variables <strong>AZURE_CLIENT_ID</strong>, <strong>AZURE_TENANT_ID</strong>, and <strong>AZURE_CLIENT_SECRET </strong>as <em><strong>Environment variables </strong></em>or as <em><strong>Application settings </strong></em>are defined with values. </p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-AD-1024x551.jpg" alt="Azure App Service Configuration page showing application settings AZURE_CLIENT_ID, AZURE_CLIENT_SECRET, and AZURE_TENANT_ID with hidden values." class="wp-image-21733" width="676" height="363" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-AD-1024x551.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-AD-300x161.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-AD-768x413.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-AD-785x422.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-AD.jpg 1097w" sizes="auto, (max-width: 676px) 100vw, 676px" /></figure>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-get-value-for-azure_client_id--azure_tenant_id--azure_client_secret">Get Value for AZURE_CLIENT_ID ,  AZURE_TENANT_ID , AZURE_CLIENT_SECRET</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s now see how to get value for  &#8220;AZURE_CLIENT_ID&#8221;, &#8220;AZURE_CLIENT_SECRET&#8221;, &#8220;AZURE_TENANT_ID&#8221; .</p>



<p class="wp-block-paragraph"></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>All these IDs (AZURE_CLIENT_ID,  AZURE_TENANT_ID, AZURE_CLIENT_SECRET ) are needed to authenticate/Identify the Application with Azure cloud. </p></blockquote>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">To get the defined values please go to the Azure default directory and click on the Application object</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><em><strong>Home -&gt; Default Directory&nbsp;&#8211; &gt;  App registrations</strong></em></p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="827" height="343" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-application-object.jpg" alt="Azure KeyVault java example" class="wp-image-21736" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-application-object.jpg 827w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-application-object-300x124.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-application-object-768x319.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-define-access-policy-using-application-object-785x326.jpg 785w" sizes="auto, (max-width: 827px) 100vw, 827px" /></figure>



<p class="wp-block-paragraph">So above,</p>



<p class="wp-block-paragraph"></p>



<ul class="wp-block-list"><li>&#8220;<strong><em>AZURE_CLIENT_ID&#8221;</em></strong>  is equal to Application(client) ID as defined in the above screenshot.</li></ul>



<p class="wp-block-paragraph"></p>



<ul class="wp-block-list"><li> &#8220;<strong>AZURE_TENANT_ID</strong>&#8221;  is equal to Directory(tenant) ID as defined in the above screenshot.</li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">So so far we got the value  &#8220;AZURE_CLIENT_ID&#8221; and &#8220;AZURE_TENANT_ID&#8221;  using the above-highlighted credentials.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Next &#8220;<strong>AZURE_CLIENT_SECRET</strong>&#8221; can be generated for the application object using the below steps.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please go to Azure Directory- &gt; App registration -&gt; Click on your Application</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Next click on the <em><strong>Certificates and Secretes -&gt; Click on New Client Secretes</strong></em></p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image"><img decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/image-3-1024x958.png" alt="Azure KeyVault node js example"/></figure>



<p class="wp-block-paragraph"></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
private IActionResult GetClientScrets()
        {
            SecretClientOptions options = new SecretClientOptions()
            {
                Retry =
                {
                    Delay= TimeSpan.FromSeconds(2),
                    MaxDelay = TimeSpan.FromSeconds(16),
                    MaxRetries = 5,
                    Mode = RetryMode.Exponential
                }
            };

            string keyVaultUrl = _configuration&#x5B;&quot;VaultURI&quot;];
            var client = new SecretClient(vaultUri: new Uri(keyVaultUrl), credential: new DefaultAzureCredential(),options);
            KeyVaultSecret secret = client.GetSecret(&quot;YourSecreteCode&quot;);
            return Ok(&quot;Your Secrete is &quot; + secret.Value);
        }
</pre></div>


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s now execute the WebApp URL and verify the Vault secrets.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="267" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/image-2-1024x267.png" alt="Browser window at thecodebuzzappserviceplan.azurewebsites.net displaying the text &#x27;Your Secrete is -you are beautiful !&#x27;" class="wp-image-21776" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/image-2-1024x267.png 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-2-300x78.png 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-2-768x201.png 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-2-1536x401.png 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-2-785x205.png 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-2.png 1731w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading" id="aioseo-approach-2---authenticate-the-application-using-msi--managed-service-identity"><strong>Approach 2 &#8211; Authenticate the Application using MSI ( Managed Service Identity </strong></h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">We can bootstrap the authentication code within the ASP.NET API pipeline using managed service identity feature of the Azure cloud.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><a href="https://thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/">Managed Service Identity (MSI)</a> is a technique to automatically manage the identity in Azure Active Directory(Azure AD).  Key Vault service can be leveraged without having any token or credentials in your code which is generally needed as the first-time validation/authentication.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">For more details please visit this article-<strong><em> <a href="https://www.thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/" target="_blank" rel="noreferrer noopener" title="Secure secrets using Azure KeyVault MSI with examples">Secure secrets using Azure KeyVault MSI with examples</a></em></strong></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Other references :</em></strong></p>



<p class="wp-block-paragraph"></p>



<ul class="has-medium-font-size wp-block-list"><li><a href="https://www.thecodebuzz.com/set-configuration-azure-using-app-service-azure-cli/" target="_blank" rel="noreferrer noopener" title="Set Configuration in Azure using App Service">Set Configuration in Azure using App Service</a></li></ul>



<ul class="has-medium-font-size wp-block-list"><li><a href="https://www.thecodebuzz.com/configuration-in-net-core-2-1/" target="_blank" rel="noreferrer noopener" title="Configuration in ASP.NET Core">Managing Configuration in ASP.NET Core</a></li></ul>



<p class="wp-block-paragraph"></p>



<hr>



<p class="wp-block-paragraph"></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2>Protect the client secret and run locally without it</h2>

<p>The client secret is a credential, and it expires. Treat it like a password: keep it only in App Service application settings or environment variables, never in source control, and set a calendar reminder to rotate it before the expiry date.</p>

<h3>How do you rotate an expiring client secret?</h3>

<p>An expired secret is a common cause of authentication failures that appear suddenly with no code change. Rotate in this order so the app never has a gap:</p>

<ol>
<li><strong>Create:</strong> add a new client secret to the app registration.</li>
<li><strong>Update:</strong> put the new value in the <code>AZURE_CLIENT_SECRET</code> setting and restart the app.</li>
<li><strong>Delete:</strong> remove the old secret once the app works with the new one.</li>
</ol>

<h3>Which credentials are stronger than a client secret?</h3>

<p>A client secret is a shared string that anyone can copy. These options reduce that risk:</p>

<ul>
<li><strong>Certificate credential:</strong> harder to leak by accident, but you must manage certificate renewal.</li>
<li><strong>Federated credentials or workload identity:</strong> no stored secret at all, but the host must be able to issue a trusted token.</li>
<li><strong>Managed identity:</strong> Azure handles the credential for you, and it is the best choice when the host supports it.</li>
</ul>

<p>The client secret is still reasonable for hosts outside Azure and for quick setups. Just keep its scope small and its lifetime short.</p>

<h3>Should you use DefaultAzureCredential in production?</h3>

<p>Use a narrower credential in production. <code>DefaultAzureCredential</code> is convenient, but it tries several credential types in sequence. Its environment credential is the one that reads <code>AZURE_CLIENT_ID</code>, <code>AZURE_TENANT_ID</code> and <code>AZURE_CLIENT_SECRET</code>.</p>

<p>When something fails, you then have to work out which of those attempts mattered. A single specific credential, or a <code>ChainedTokenCredential</code> with only the types you expect, gives you a shorter and clearer error.</p>

<blockquote class="tcb-plain-english" style="border-left:4px solid #f59e0b;background:#fffbeb;margin:18px 0;padding:10px 16px;font-style:normal"><p><strong>In plain English:</strong> A credential chain is like trying keys on a ring until one opens the door. A short ring is quicker to check when the door stays shut.</p></blockquote>

<h3>How do you run locally without a client secret?</h3>

<p>Put <code>AzureCliCredential</code> in the chain and sign in with <code>az login</code>. Your own account then reads the vault, so no secret is saved on your machine. Your account needs permission on the vault.</p>

<p>For developer-only values, layer user secrets on top of the Key Vault configuration source. Add them after the vault so they override it locally.</p>

<h3>What should you check when authentication still fails?</h3>

<ul>
<li><strong>Reuse one client:</strong> <code>SecretClient</code> is thread-safe, so create one instance and share it instead of building a new one per request.</li>
<li><strong>Tenant ID:</strong> confirm <code>AZURE_TENANT_ID</code> is the directory that owns the app registration.</li>
<li><strong>Vault firewall:</strong> check the vault&#8217;s networking settings allow calls from your app&#8217;s network.</li>
</ul>




<h2>Frequently asked questions</h2>

<h3><strong>Which RBAC role does an app need to read Azure Key Vault secrets?</strong></h3>
<p>Assign <strong>Key Vault Secrets User</strong> to the app&#8217;s service principal. It gives read-only access to secret values. If the app loads secrets through the <code>AddAzureKeyVault</code> configuration provider, also assign <strong>Key Vault Reader</strong> so the provider can list the secrets. Reader alone can&#8217;t read values, because it only sees metadata. Scope the role to the whole vault, or to a single secret if you want tighter control.</p>

<h3><strong>Why do I get 403 Forbidden from Key Vault right after granting access?</strong></h3>
<p>Role assignments can take several minutes to propagate, so wait a few minutes and retry first. If the 403 persists, check these:</p>
<ul>
<li><strong>Access model:</strong> the vault must use RBAC rather than access policies, or your role assignment is ignored.</li>
<li><strong>Principal:</strong> the role must be assigned to the right service principal, the one behind your <code>AZURE_CLIENT_ID</code>.</li>
<li><strong>Tenant:</strong> <code>AZURE_TENANT_ID</code> must be the correct directory.</li>
<li><strong>Client secret:</strong> it must not have expired.</li>
<li><strong>Firewall:</strong> the vault&#8217;s network rules must allow the caller.</li>
</ul>

<h3><strong>How do I name nested settings like Db:Password in Key Vault?</strong></h3>
<p>Use a double dash in the secret name. Key Vault secret names can&#8217;t contain colons, so you create a secret called <code>Db--Password</code>. When the Key Vault configuration provider loads it, the name maps to the configuration key <code>Db:Password</code>, and your existing <code>IConfiguration</code> code works unchanged.</p>

<h3><strong>Does the app pick up Key Vault secret changes without a restart?</strong></h3>
<p>Not by default. The configuration provider&#8217;s <code>ReloadInterval</code> option defaults to <code>null</code>, so secrets are loaded once at startup. Set <code>ReloadInterval</code> to a <code>TimeSpan</code> and the provider polls the vault for changes. If you call <code>SecretClient</code> directly, as in the example above, it reads the current value on every call, so decide deliberately how long to cache it. Create one <code>SecretClient</code> and reuse it rather than building a new one per request.</p><p>The post <a href="https://thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret/">Secure secrets using Azure KeyVault -Approach II</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Secure secrets using Azure KeyVault MSI with examples</title>
		<link>https://thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/</link>
					<comments>https://thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/#respond</comments>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Fri, 01 Apr 2022 03:54:00 +0000</pubDate>
				<category><![CDATA[Azure HowTo]]></category>
		<category><![CDATA[azure key vault best practices]]></category>
		<category><![CDATA[azure key vault documentation]]></category>
		<category><![CDATA[azure key vault implementation in c# .net core]]></category>
		<category><![CDATA[azure key vault is used to store secrets for]]></category>
		<category><![CDATA[azure key vault local development c#]]></category>
		<category><![CDATA[azure key vault MSI example]]></category>
		<category><![CDATA[azure key vault python]]></category>
		<category><![CDATA[azure.security.keyvault.secrets example c#]]></category>
		<category><![CDATA[Secure secrets using Azure KeyVault with examples]]></category>
		<category><![CDATA[vault using managed secured identity]]></category>
		<guid isPermaLink="false">https://www.thecodebuzz.com/?p=21694</guid>

					<description><![CDATA[<p>Secure secrets using Azure KeyVault with examples Today in this article, we will see how to Secure secrets using Azure KeyVault with examples. We will see step-by-step detailed examples of how to secure and use secretes using the KeyVault service. Today in this article, we will cover below aspects, We will see how to use [&#8230;]</p>
<p>The post <a href="https://thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/">Secure secrets using Azure KeyVault MSI with examples</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></description>
										<content:encoded><![CDATA[<h1 class="wp-block-heading">Secure secrets using Azure KeyVault with examples</h1>



<figure class="wp-block-image size-full is-resized"><a href="https://www.thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/" target="_blank" rel="noopener"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-1-1.jpg" alt="Secure secrets using Azure KeyVault MSI in C#.NET" class="wp-image-21786" width="579" height="454" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-1-1.jpg 506w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-1-1-300x235.jpg 300w" sizes="auto, (max-width: 579px) 100vw, 579px" /></a></figure>



<p class="wp-block-paragraph">Today in this article, we will see how to Secure secrets using Azure KeyVault with examples. We will see step-by-step detailed examples of how to secure and use secretes using the KeyVault service. </p>



<p class="wp-block-paragraph">Today in this article, we will cover below aspects,</p>



<div class="wp-block-aioseo-table-of-contents"><ul><li><a href="#aioseo-secure-secrets-using-azure-keyvault---getting-started">Secure secrets using Azure KeyVault &#8211; Getting Started</a></li><li><a href="#aioseo-prerequisites">Prerequisites</a></li><li><a href="#aioseo-azure-key-vault-service-setup">Azure Key Vault Service Setup</a></li><li><a href="#aioseo-create-azure-key-vault-service-using-azure-portal">Create Azure Key Vault service using Azure Portal</a></li><li><a href="#aioseo-define-configuration-of-keyvault">Define configuration of KeyVault</a></li><li><a href="#aioseo-add-access-policy-using-managed-identity-for-azure-keyvault">Add Access policy using Managed Identity for Azure KeyVault</a></li><li><a href="#aioseo-add-secretes-to-keyvault">Add Secretes to KeyVault</a></li><li><a href="#aioseo-using-azure-cli-for-adding-managed-identity-for-the-keyvault-service">Using Azure CLI for adding Managed Identity for the KeyVault service</a></li><li><a href="#aioseo-create-asp-net-core-api-or-mvc-application-using-net-6-or-net-5">Create ASP.NET Core API or MVC application using .NET 6 or .NET 5</a></li></ul></div>



<p class="wp-block-paragraph">We will see how to use<strong><em> Managed identity for accessing Azure Key vault resources </em></strong>and will also cover how to access Azure key vault resources without using the Managed identity.</p>



<p class="wp-block-paragraph">We will use<strong> Azure portal</strong> and <strong>Azure CLI</strong> commands both ways to achieve the same.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">In this tutorial, we will deploy the web application to&nbsp;<a href="https://docs.microsoft.com/en-us/azure/app-service/overview" target="_blank" rel="noreferrer noopener"><em>Azure App Service.</em></a> We will use the Azure Key Vault secret client library for .NET&nbsp;and the&nbsp;Azure CLI.&nbsp;</p>



<p class="wp-block-paragraph"></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Managed identity let you authenticate to any service inlcuding Key Vault that supports Azure AD authentication. </p><p>Also You need not have to store keys or secretes in the code.</p></blockquote>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">You&#8217;ll use a managed identity to authenticate your Azure web app with an Azure key vault using</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Azure KeyVault service is language agnostics (like any other Azure services offered) and can be used for <em><strong> .NET, JAVA, Node JS, and Pytho</strong>n </em>application as required.</p>



<p class="wp-block-paragraph"></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Below discussed high-level steps can be followed in any language of your choice.</p></blockquote>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">We will use a simple .NET API which will connect to Azure Vault to get the secured credentials like Connection string etc.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">KeyVault lets you securely access secretes and sensitive information from within your applications. These Keys, secrets, and certificates are protected without you having to write the code yourself, and you can easily use them from your applications.</p>



<p class="wp-block-paragraph"></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>Authentication in Key Vault works using Azure Active Directory (Azure AD) where, Azure AD authenticates the identity of any given&nbsp;<strong>security principal</strong>.</p></blockquote>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Before we get started we will perform the basic configuration required for the Azure Key Vault service to function properly.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">We will use a simple application that we will be hosting in Azure Cloud. This application will use the Vault to get the sensitive credentials.</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-secure-secrets-using-azure-keyvault---getting-started">Secure secrets using Azure KeyVault &#8211; Getting Started</h2>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-prerequisites">Prerequisites </h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Before we get started with actual Azure Vault implementation please make sure you have the below prerequisites defined already in your Azure cloud account,</p>



<p class="wp-block-paragraph"></p>



<ul class="has-medium-font-size wp-block-list"><li>Create a Resource group( if not already exist )</li><li>Create an App Service plan</li><li>Create Azure WebApp (App Service) in the App service plan</li></ul>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-azure-key-vault-service-setup"><strong>Azure Key Vault Service Setup</strong></h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">We can set up the Azure Key Vault service using multiple approaches.</p>



<p class="wp-block-paragraph">We will mainly see two approaches i.e using Azure CLI and Azure Portal in this article</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-create-azure-key-vault-service-using-azure-portal"><strong>Create Azure Key Vault service using Azure Portal</strong></h2>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="622" height="311" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service.jpg" alt="Azure KeyVault with examples" class="wp-image-21729" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service.jpg 622w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-300x150.jpg 300w" sizes="auto, (max-width: 622px) 100vw, 622px" /></figure>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-define-configuration-of-keyvault">Define configuration of KeyVault </h2>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-create-keyvault-account.jpg" alt="" class="wp-image-21730" width="613" height="705" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-create-keyvault-account.jpg 774w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-create-keyvault-account-261x300.jpg 261w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-create-keyvault-account-768x883.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-create-keyvault-account-452x520.jpg 452w" sizes="auto, (max-width: 613px) 100vw, 613px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-add-access-policy-using-managed-identity-for-azure-keyvault">Add Access policy using Managed Identity for Azure KeyVault</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please define the access policy as required for the vault service.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-full is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD.jpg" alt=" Azure KeyVault C# example" class="wp-image-21731" width="610" height="438" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD.jpg 815w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-300x215.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-768x551.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-724x520.jpg 724w" sizes="auto, (max-width: 610px) 100vw, 610px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<ul class="wp-block-list"><li>Above I have defined only &#8220;Get&#8221; access to key vault service.</li></ul>



<p class="wp-block-paragraph"> </p>



<ul class="wp-block-list"><li>For the<strong> “Select Principal”</strong> option, select the Azure Web App that you enabled Identity Management previously.</li></ul>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/image-1-1024x548.png" alt="" class="wp-image-21775" width="368" height="196" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/image-1-1024x548.png 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-1-300x160.png 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-1-768x411.png 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-1-785x420.png 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/image-1.png 1045w" sizes="auto, (max-width: 368px) 100vw, 368px" /></figure>



<p class="wp-block-paragraph">Once done your Vault account will be created successfully </p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Below highlighted URL is your <strong><em>AzureKy Vault </em></strong>URL.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="234" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-and-create-keyvault-account-1024x234.jpg" alt="" class="wp-image-21732" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-and-create-keyvault-account-1024x234.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-and-create-keyvault-account-300x68.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-and-create-keyvault-account-768x175.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-and-create-keyvault-account-785x179.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-azure-key-vault-service-define-access-policy-using-AD-and-create-keyvault-account.jpg 1507w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please make a note of Vault URI &#8220;<em>https://thecodebuzz-key-vault.vault.azure.net/</em>&#8221; this is going to be used on the C# logic to connect to Vault and fetch the secretes. We will see more on the same in the below section.</p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-add-secretes-to-keyvault">Add Secretes to KeyVault</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s now go to our Key Vault and add application secrete,</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/image-3-1024x958.png" alt="Azure KeyVault node js example" class="wp-image-21777" width="637" height="595"/></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Above I have added new secretes called &#8220;<strong><em>YourSecreteCode</em></strong>&#8221; with a value of &#8220;<em><strong>you are beautiful</strong></em>&#8220;</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-using-azure-cli-for-adding-managed-identity-for-the-keyvault-service"><strong>Using Azure CLI for adding Managed Identity for the KeyVault service </strong></h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Alternatively, </em></strong>If interested we can perform the above steps using CLI as well. </p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">One can use the AZ CLI command to create an Azure Key Vault service account as below,</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">The below command can be used to create an Azure Key Vault account.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault create --resource-group "thecodebuzz-group" --name "thecodebuzz-vault"
</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><span style="font-size: revert; color: initial;">assign-identity command to create the identity for this application</span> </strong></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az webapp identity assign --name "&lt;App-Service-Name&gt;" --resource-group "&lt;Resource-Group-Name&gt;"</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az webapp identity assign --name "thecodebuzz-web-app-service" --resource-group "thecodebuzz-group" </pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Once executed successfully,</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">You shall see the output below,</p>



<p class="wp-block-paragraph"></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: plain; title: ; notranslate">
{
   &quot;principalId&quot;: &quot;4a6bdc47-xxx-4402-xxxx-fc2861108d1c&quot;,
   &quot;tenantId&quot;: &quot;xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&quot;,
   &quot;type&quot;: &quot;SystemAssigned&quot;
 }
</pre></div>


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">As a next step, please run the below command to set the policy.</p>



<p class="wp-block-paragraph"></p>



<ul class="wp-block-list"><li>The web app application is given permission to do&nbsp;<strong>get</strong>&nbsp;or <strong>list</strong>&nbsp;operations on your key vault bypassing the <strong><em>principalID </em></strong>obtained above </li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Command</strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">az keyvault set-policy --name '&lt;key-Vault-Name&gt;' --object-id &lt;principalId&gt; --secret-permissions get</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong>Example </strong></p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size"> az keyvault set-policy --name 'thecodebuzz-key-vault' --object-id '4a6bdc47-xxxx-4402-xxxx-fc2861108d1c' secret-permissions get </pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<h2 class="wp-block-heading" id="aioseo-create-asp-net-core-api-or-mvc-application-using-net-6-or-net-5">Create ASP.NET Core API or MVC application using .NET 6 or .NET 5</h2>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Let&#8217;s create our sample application here. Our target will be to deploy the application cloud Azure app service associated with App Service Plan.</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service-1024x704.jpg" alt="Secure secrets using Azure KeyVault with examples" class="wp-image-21725" width="542" height="372" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service-1024x704.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service-300x206.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service-768x528.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service-1536x1056.jpg 1536w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service-756x520.jpg 756w, https://thecodebuzz.com/wp-content/uploads/2022/04/secure-api-secrets-using-azure-key-vault-service.jpg 1745w" sizes="auto, (max-width: 542px) 100vw, 542px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Add below two Nuget packages,</p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">Install-Package <a href="https://www.nuget.org/packages/Azure.Security.KeyVault.Secrets" target="_blank" rel="noreferrer noopener">Azure.Security.KeyVault.Secrets</a> -Version 4.3.0</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">This library allows you to securely store and control access to tokens, passwords, API keys, and other secrets. This library offers operations to create, retrieve, update, delete, purge, backup, restore, and list the secrets and their versions.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">and</p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">Install-Package <a href="https://www.nuget.org/packages/Azure.Identity" target="_blank" rel="noreferrer noopener">Azure.Identity</a> -Version 1.6.0</pre>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">This library provides Azure Active Directory token authentication support. </p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Please add below <em><strong>using namespaces</strong></em>,</p>



<p class="wp-block-paragraph"></p>



<pre class="wp-block-preformatted has-medium-font-size">using Azure.Identity;

using Azure.Security.KeyVault.Secrets;</pre>



<p class="wp-block-paragraph"></p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p>You can use the same logic as it is Console/API or other type of Application as well</p></blockquote>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Open your project solution in Visual Studio. Go to<strong><em> Program.cs</em></strong> and add the below-highlighted code</p>



<p class="wp-block-paragraph"></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; highlight: [10,11,12,13,14,15,16,17,18,19,20,21,22,23]; title: ; notranslate">
public class Program
    {
        public static void Main(string&#x5B;] args)
        {
            CreateHostBuilder(args).Build().Run();
        }

        public static IHostBuilder CreateHostBuilder(string&#x5B;] args) =&gt;
            Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((context, config) =&gt;
            {
                var settings = config.Build();

                if (!context.HostingEnvironment.IsDevelopment())
                {
                    var keyVaultEndpoint = settings&#x5B;&quot;VaultURI&quot;];
                    if (!string.IsNullOrEmpty(keyVaultEndpoint))
                    {
                        var azureServiceTokenProvider = new AzureServiceTokenProvider();
                        var keyVaultClient = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback(azureServiceTokenProvider.KeyVaultTokenCallback));
                        config.AddAzureKeyVault(keyVaultEndpoint, keyVaultClient, new DefaultKeyVaultSecretManager());
                    }
                }

            }).ConfigureWebHostDefaults(webBuilder =&gt;
               {
                   webBuilder.UseStartup&lt;Startup&gt;();
               });
    }
</pre></div>


<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">That&#8217;s all. Now Azure Key Vault credentials will become part of your <strong><em>IConfiguration </em></strong>root object along with all available configurations.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">The above steps will help you manage the azure credentials just like any other configuration and hence let you handle updates or edits to key vault secrets based on how you set your configuration in the API or Application pipeline.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">For Accessing Azure Key Vault credentials you need to inject the <strong><em><a href="https://www.thecodebuzz.com/createdefaultbuilder-configuration-management-net-core-and-asp-net-core/" target="_blank" rel="noreferrer noopener" title="CreateDefaultBuilder and Configuration Management in .NET">IConfiguration </a></em></strong>interface in the required module of your choice.</p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Example </em></strong></p>



<p class="wp-block-paragraph"></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: csharp; highlight: [4]; title: ; notranslate">
 public IActionResult Index()
        {

            string keyVaultUrl = _configuration&#x5B;&quot;YourSecreteCode&quot;];

            return Ok(&quot;Your Secrete is -&quot; + keyVaultUrl);
        }
</pre></div>


<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="913" height="166" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-local-debug.jpg" alt="Secure secrets using Azure KeyVault C#.NET" class="wp-image-21828" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-local-debug.jpg 913w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-local-debug-300x55.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-local-debug-768x140.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-local-debug-785x143.jpg 785w" sizes="auto, (max-width: 913px) 100vw, 913px" /></figure>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph">Similarly, if you hit the WebApp endpoint,</p>



<p class="wp-block-paragraph"></p>



<figure class="wp-block-image size-large is-resized"><img loading="lazy" decoding="async" src="https://www.thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-Azure-endpoint-1024x350.jpg" alt="" class="wp-image-21830" width="419" height="143" srcset="https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-Azure-endpoint-1024x350.jpg 1024w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-Azure-endpoint-300x102.jpg 300w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-Azure-endpoint-768x262.jpg 768w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-Azure-endpoint-785x268.jpg 785w, https://thecodebuzz.com/wp-content/uploads/2022/04/Secure-secrets-using-Azure-KeyVault-using-Visual-Studio-Configure-Managed-identity-C-Azure-endpoint.jpg 1288w" sizes="auto, (max-width: 419px) 100vw, 419px" /></figure>



<p class="wp-block-paragraph">If you are interested to know non-msi approach by using enviornment variable setup , please visit below article- <a href="https://www.thecodebuzz.com/secure-secrets-using-azure-keyvault-approach-azure-client-secret/" title="Secure secrets using Azure KeyVault -Approach II" target="_blank" rel="noreferrer noopener"><em><strong>Secure secrets using Azure KeyVault -Approach II</strong></em></a></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"><strong><em>Other references :</em></strong></p>



<p class="wp-block-paragraph"></p>



<ul class="has-medium-font-size wp-block-list"><li><a href="https://www.thecodebuzz.com/set-configuration-azure-using-app-service-azure-cli/" target="_blank" rel="noreferrer noopener" title="Set Configuration in Azure using App Service">Set Configuration in Azure using App Service</a></li></ul>



<ul class="has-medium-font-size wp-block-list"><li><a href="https://www.thecodebuzz.com/configuration-in-net-core-2-1/" target="_blank" rel="noreferrer noopener" title="Configuration in ASP.NET Core">Managing Configuration in ASP.NET Core</a></li></ul>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:18px">Do you have any <strong>comments or ideas or any better </strong>suggestions to share?</p>



<p class="has-small-font-size wp-block-paragraph"></p>



<p class="wp-block-paragraph" style="font-size:18px">Please sound off your comments below.</p>



<p class="has-medium-font-size wp-block-paragraph"></p>



<p class="has-medium-font-size wp-block-paragraph"><strong>Happy Coding </strong>!!</p>



<p class="wp-block-paragraph"></p>



<hr>



<p class="wp-block-paragraph"></p>



<p class="has-background" style="background-color:#b6d9ac;font-size:18px"><br>Please <strong><em>bookmark </em></strong>this page and <em><strong>share </strong></em>it with your friends.                                                    Please <a href="https://www.thecodebuzz.com/subscription/" target="_blank" rel="noreferrer noopener"><em><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-luminous-vivid-orange-color"><strong>Subscribe</strong> </mark></em></a>to the blog to receive notifications on freshly published (2026) best practices and guidelines for software design and development.</p>




<br>



<hr>



<p class="wp-block-paragraph"></p>



<p class="wp-block-paragraph"></p><p>The post <a href="https://thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/">Secure secrets using Azure KeyVault MSI with examples</a> first appeared on <a href="https://thecodebuzz.com">TheCodeBuzz</a>.</p>]]></content:encoded>
					
					<wfw:commentRss>https://thecodebuzz.com/secure-secrets-azure-key-vault-examples-csharp-java-python-nodejs/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
