<p>I am trying to implement CI/CD pipeline for my APIs on AKS. i have successfully configured the CI and CD pipelines which works quite smoothly, now i have 2 environments named Prod and Slot to enable 0 down time.</p>

<p>I found the <a href="https://martinfowler.com/bliki/BlueGreenDeployment.html" rel="nofollow noreferrer"><code>blue/green deployment</code></a> method. And in my CD pipeline i am trying to set the current slot and pass it to the helm upgrade command in the next step</p>

<pre><code>currentSlot=`(helm --client-only get values --all api-poi | grep -Po 'productionSlot: \K.*')`

if [ "$currentSlot" == "blue" ]; then
    newSlot="green"
else
    newSlot="blue"
fi
</code></pre>

<p>but it always set the newslot as empty. what could be the reason?</p>

<pre><code>$(newSlot).enabled=true
</code></pre>

devops azure
<p>Try with Azure CLI command instead of Bash script with the <strong><code>az aks get-credentials --name</code></strong>  involved. </p>

<p>Alternate CLI command would be</p>

<pre><code>az aks get-credentials --name $(AKSClusterName) --resource-group $(AKSResourceGroup)
currentSlot=$(helm get values --all $(chartName) |  grep -oP '(?&lt;=productionSlot: ).*')
if [ "$currentSlot" == "blue" ]; then
    newSlot="green"
else
    newSlot="blue"
fi
</code></pre>

<p>you need to set those AKSClusterName,AKSResourceGroup,chartName values in the pipeline or hard code them</p>
