How to deploy a bicep template from a .Net web app using Bicep.Core sdk package #16223
-
| Hi, I am tying to integrate deploying resources from a BICEP template from a .NET web app. My solution involves getting a bicep template from a storage account container, compiling it using the BicepCompiler service and deploying the template at the required scope. The BICEP template I am using references modules from a repository on Azure Container Registry. I have a bicepconfig.json that maps the alias and login cred type to use: Materials referenced: 
 I have the web app set up to use the managed identity credential to connect to other Azure resources like key vault/Cosmos DB. Could I get some pointers on how to use the same identity to also pull the images from the ACR repo? | 
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
| I have ran into the same issue trying to use bicep.core to deploy bicep from my api layer and have not been able to solve this issue, hopefully someone from the team could look more into this as I get restoration failures when trying to deploy a file in the same area of code. Any guidance would be greatly appreciated or if you resolve please update here @SunidhiShastry | 
Beta Was this translation helpful? Give feedback.
-
| I think the error message is telling you that the SDK isn't able to unambiguously resolve the managed identity to use. Have you tried configuring the "cloud.credentialOptions.managedIdentity" setting in your bicepconfig.json? {
  "moduleAliases": { ... },
  "cloud": {
    "currentProfile": "AzureCloud",
    "credentialPrecedence": [
      "ManagedIdentity"
    ],
    "credentialOptions": {
      "managedIdentity": {
        "type": "UserAssigned",
        // TODO either set clientId or resourceId
        "resourceId": "...",
        "clientId": "..."
      }
    }
  }
} | 
Beta Was this translation helpful? Give feedback.
I think the error message is telling you that the SDK isn't able to unambiguously resolve the managed identity to use.
Have you tried configuring the "cloud.credentialOptions.managedIdentity" setting in your bicepconfig.json?
{ "moduleAliases": { ... }, "cloud": { "currentProfile": "AzureCloud", "credentialPrecedence": [ "ManagedIdentity" ], "credentialOptions": { "managedIdentity": { "type": "UserAssigned", // TODO either set clientId or resourceId "resourceId": "...", "clientId": "..." } } } }