Goal:
Securely get Azure resources by tag from Azure pipeline.
Details:
I have an azure-pipelines.yaml
that builds a static website and saves it to a hard-coded storage account. This is a security vulnerability.
I now need to update the file to handle blue-green deployments, azure-pipelines.yaml
will need to get the storage account that's tagged as the current production storage account, i.e. something like (just a bash script)
prod_storage_acct_name=$(az resource list --is_prod=true --query [0].name)
This works, BUT, it requires a prior az login -u $un -p $pwd
, which I test with my user. Obviously I am not going to put my personal user in the pipeline, so the questions are...
Questions:
- Is the best way to get an Azure pipeline access to another resource a service principal acct?
- Do pipelines have some built in way to configure their access WITHOUT specifying a distinct service principal, since they are "built in" Azure processes? (Get own Service Principal Name in an Azure DevOps Powershell pipeline task seems to imply that a service principal is built in)
- Is there some better way to do this that I am completely missing?
IF I need to go with #1, what's the best security practice here? Do I just throw the service principal password into key vault and reference it in the build script?
Maybe an intuitive way of asking: Is there any way to basically say "I am a pipeline, I live on Azure, let me use my own access for this query"?