<p>I am trying to update my deployment with latest image content on Azure Kubernetes Service every time some code is committed to github . I have made a stage in my build pipeline to build and push the image on docker hub which is working perfectly fine. however in my release pipeline the image is being used as an artifact and is being deployed to the Azure Kubernetes Service , but the problem is that the image on AKS in not updating according to the image pushed on Docker Hub with latest code.</p>

<p>Right now each time some commit happens i have to manually update the image on AKS via the Command</p>

<p><em>kubectl set image deployment/demo-microservice demo-microservice=customerandcontact:contact</em> </p>

<p>My Yaml File</p>

<p><a href="https://i.stack.imgur.com/jAMCZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jAMCZ.png" alt="enter image description here"></a></p>

<p>Can anyone tell the error/changes if any in my yaml file to automatically update the image on AKS.</p>

<p>When you relese a new image to the container registry under the same tag it does not mean anything to Kubernetes. If you run <code>kubectl apply -f ...</code> and the image name and tag remains the same, it still won't do anything as there is no configuration change. There are two options:</p>

<ol>
<li><p>Give a new tag on each build and change the <code>:contact</code> to the new tag in the yaml and run kubectl apply</p></li>
<li><p>For dev environment only (do not do it in Stage or Prod) leave the same tag (usually a tag <code>:latest</code> is used) and after a new image is deployed to registry run <code>kubectl delete pod demo-microservice</code>. Since you've set image pull policy to Always, this will cause Kubernetes pull a new image from the registry and redeploy the pod.</p></li>
</ol>

<p>The second approach is a workaround just for testing.</p>
