Azure Storage SAS token working on localhost but not when deployed on Azure Kubernetes Azure Storage SAS token working on localhost but not when deployed on Azure Kubernetes kubernetes kubernetes

Azure Storage SAS token working on localhost but not when deployed on Azure Kubernetes


After a long time scratching my head to find a solution, I figured out where the problem was.

It had nothing to do with the Python library for accessing the blob, but rather with the environment variables in the Kubernetes pod.

The environment variables were passed to Kubernetes as secrets using a yaml file (as explained in this link).Using this method, the secret needs to be base64 encoded. For this I was using the following

echo 'secret' | base64>> c2VjcmV0Cg==

In this way however, the echo command appends by default a newline character to the output. What I should have used instead was

echo -n 'secret' | base64>> c2VjcmV0

This bug was particularly difficult to find especially because when printed, the wrong solution would appear to lead to the correct result

echo 'secret' | base64 | base64 -d>> secret

Anyway, I hope that my mistake will help someone in the future!