https://pulumi.com logo
#getting-started
Title
# getting-started
c

calm-tent-21096

04/03/2022, 6:40 PM
still having trouble creating resources with user-assigned identities:
Copy code
var languageIdentity = new AzureNative.ManagedIdentity.UserAssignedIdentity(name, new AzureNative.ManagedIdentity.UserAssignedIdentityArgs
        {
            ResourceGroupName = _cognitiveRg.Name,
            ResourceName = name
        });
        languageIdentity.Id.Apply(id =>
        {
            var langStorageAssignment = new AzureNative.Authorization.RoleAssignment("lang-storage-assignment", new AzureNative.Authorization.RoleAssignmentArgs
            {
                PrincipalType = AzureNative.Authorization.PrincipalType.ServicePrincipal,
                PrincipalId = languageIdentity.PrincipalId,
                RoleDefinitionId = "/subscriptions/xxx/providers/Microsoft.Authorization/roleDefinitions/ba92f5b4-2d11-453d-a403-e96b0029c9fe", // storage blob data contributor
                Scope = _coreRef.GetOutput("StorageAccountId").Apply(sa => Convert.ToString(sa) ?? string.Empty)
            });
            var searchContributorAssignment = new AzureNative.Authorization.RoleAssignment("lang-search-contributor", new AzureNative.Authorization.RoleAssignmentArgs
            {
                PrincipalType = AzureNative.Authorization.PrincipalType.ServicePrincipal,
                PrincipalId = languageIdentity.PrincipalId,
                RoleDefinitionId = "/subscriptions/xxx/providers/Microsoft.Authorization/roleDefinitions/b24988ac-6180-42a0-ab88-20f7382dd24c",
                Scope = _searchService?.Id ?? throw new Exception("Search Service not available")
            });
            language = new Account(name, new AccountArgs
            {
                Kind = "TextAnalytics",
                AccountName = name,
                Identity = new AzureNative.CognitiveServices.Inputs.IdentityArgs
                {
                    Type = AzureNative.CognitiveServices.IdentityType.UserAssigned,
                    UserAssignedIdentities =
                    {
                        { 
                            id,
                            new AzureNative.CognitiveServices.Inputs.UserAssignedIdentityArgs { PrincipalId = languageIdentity.PrincipalId } 
                        }
                    }
                },
// ...
3 Views