Repository navigation
Reference logged in account in bicep template #9092
|
I am deploying bicep templates from Azure DevOps via yaml pipelines. The pipelines use service connections configured with subscription access. Amongst other things, I am deploying key vaults and access policies. The pipeline/serviceconnection needs to be granted read access to the key vault. Currently, I deploy a key vault access policy, with a "hard coded" reference to the ObjectId of the serviceprincipal configured in the service connection. Is there any way to get the identifier from the running session instead of having a the ObjectId in the parameter file or pre-calculating it in a script task in the pipeline? |
Replies: 1 comment 2 replies
|
I don't think there is a reliable way to do this. Last year I tested and I found out that there was some storage latency in Azure that meant the deployment logs are not written fast enough to retrieve them in the same deployment. They did mention they planned to upgrade the storage, which may have been completed now, I am not sure. This was my first failed attempt:
I can try to find the thread on this, I think there was an issue opened to be able to retrieve the objectId that runs the deployment. Once I find it I will link it. -- I use a different strategy for this, however it's more complicated and involved a two stage deployment.
The command to create the SP and do the steps above, for each Resource Group 1 SP / RG.
Also I use RBAC for keyvaults, so do a 2 stage deployment, the first stage is Owner and only does RBAC and PIM assignments. Example of service connection -- Let me know if you came up with any solution in the meantime given then discussion was aged? |


I tried out this concept again and in my standalone tenant, it works fine, takes 2 minutes for the log to show up.
workaroundif possible, since it's not following a declarative model for maintaining external state.use get-azlog to look up who is running the deployment and return the objectid