@@ -364,17 +364,18 @@ public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrast
364364
365365 await ExecuteBeforeStartHooksAsync ( app , default ) ;
366366
367- var projRoles = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp-roles") ) ;
367+ var projRolesStorage = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp-roles-my-own-storage ") ) ;
368368
369- var ( rolesManifest , rolesBicep ) = await GetManifestWithBicep ( projRoles ) ;
369+ var ( rolesManifest , rolesBicep ) = await GetManifestWithBicep ( projRolesStorage ) ;
370370
371371 var expectedRolesManifest =
372372 """
373373 {
374374 "type": "azure.bicep.v0",
375- "path": "funcapp-roles.module.bicep",
375+ "path": "funcapp-roles-my-own-storage .module.bicep",
376376 "params": {
377- "my_own_storage_outputs_name": "{my-own-storage.outputs.name}"
377+ "my_own_storage_outputs_name": "{my-own-storage.outputs.name}",
378+ "principalId": "{funcapp-identity.outputs.principalId}"
378379 }
379380 }
380381 """ ;
@@ -387,50 +388,41 @@ public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrast
387388
388389 param my_own_storage_outputs_name string
389390
390- resource funcapp_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
391- name: take('funcapp_identity-${uniqueString(resourceGroup().id)}', 128)
392- location: location
393- }
391+ param principalId string
394392
395393 resource my_own_storage 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
396394 name: my_own_storage_outputs_name
397395 }
398396
399397 resource my_own_storage_StorageBlobDataContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
400- name: guid(my_own_storage.id, funcapp_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'))
398+ name: guid(my_own_storage.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'))
401399 properties: {
402- principalId: funcapp_identity.properties. principalId
400+ principalId: principalId
403401 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')
404402 principalType: 'ServicePrincipal'
405403 }
406404 scope: my_own_storage
407405 }
408406
409407 resource my_own_storage_StorageTableDataContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
410- name: guid(my_own_storage.id, funcapp_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3'))
408+ name: guid(my_own_storage.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3'))
411409 properties: {
412- principalId: funcapp_identity.properties. principalId
410+ principalId: principalId
413411 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3')
414412 principalType: 'ServicePrincipal'
415413 }
416414 scope: my_own_storage
417415 }
418416
419417 resource my_own_storage_StorageQueueDataContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
420- name: guid(my_own_storage.id, funcapp_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88'))
418+ name: guid(my_own_storage.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88'))
421419 properties: {
422- principalId: funcapp_identity.properties. principalId
420+ principalId: principalId
423421 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88')
424422 principalType: 'ServicePrincipal'
425423 }
426424 scope: my_own_storage
427425 }
428-
429- output id string = funcapp_identity.id
430-
431- output clientId string = funcapp_identity.properties.clientId
432-
433- output principalId string = funcapp_identity.properties.principalId
434426 """ ;
435427 output . WriteLine ( rolesBicep ) ;
436428 Assert . Equal ( expectedRolesBicep , rolesBicep ) ;
@@ -455,17 +447,18 @@ public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrast
455447
456448 await ExecuteBeforeStartHooksAsync ( app , default ) ;
457449
458- var projRoles = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp-roles") ) ;
450+ var projRolesStorage = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp-roles-my-own-storage ") ) ;
459451
460- var ( rolesManifest , rolesBicep ) = await GetManifestWithBicep ( projRoles ) ;
452+ var ( rolesManifest , rolesBicep ) = await GetManifestWithBicep ( projRolesStorage ) ;
461453
462454 var expectedRolesManifest =
463455 """
464456 {
465457 "type": "azure.bicep.v0",
466- "path": "funcapp-roles.module.bicep",
458+ "path": "funcapp-roles-my-own-storage .module.bicep",
467459 "params": {
468- "my_own_storage_outputs_name": "{my-own-storage.outputs.name}"
460+ "my_own_storage_outputs_name": "{my-own-storage.outputs.name}",
461+ "principalId": "{funcapp-identity.outputs.principalId}"
469462 }
470463 }
471464 """ ;
@@ -478,30 +471,21 @@ public async Task AddAzureFunctionsProject_WorksWithAddAzureContainerAppsInfrast
478471
479472 param my_own_storage_outputs_name string
480473
481- resource funcapp_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
482- name: take('funcapp_identity-${uniqueString(resourceGroup().id)}', 128)
483- location: location
484- }
474+ param principalId string
485475
486476 resource my_own_storage 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
487477 name: my_own_storage_outputs_name
488478 }
489479
490480 resource my_own_storage_StorageBlobDataOwner 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
491- name: guid(my_own_storage.id, funcapp_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'))
481+ name: guid(my_own_storage.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'))
492482 properties: {
493- principalId: funcapp_identity.properties. principalId
483+ principalId: principalId
494484 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b')
495485 principalType: 'ServicePrincipal'
496486 }
497487 scope: my_own_storage
498488 }
499-
500- output id string = funcapp_identity.id
501-
502- output clientId string = funcapp_identity.properties.clientId
503-
504- output principalId string = funcapp_identity.properties.principalId
505489 """ ;
506490 output . WriteLine ( rolesBicep ) ;
507491 Assert . Equal ( expectedRolesBicep , rolesBicep ) ;
@@ -528,19 +512,20 @@ public async Task MultipleAddAzureFunctionsProject_WorksWithAddAzureContainerApp
528512
529513 await ExecuteBeforeStartHooksAsync ( app , default ) ;
530514
531- var projRoles = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp-roles") ) ;
532- var projRoles2 = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp2-roles") ) ;
515+ var projRolesStorage = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp-roles-my-own-storage ") ) ;
516+ var projRolesStorage2 = Assert . Single ( model . Resources . OfType < AzureProvisioningResource > ( ) . Where ( r => r . Name == $ "funcapp2-roles-funcstorage634f8 ") ) ;
533517
534- var ( rolesManifest , rolesBicep ) = await GetManifestWithBicep ( projRoles ) ;
535- var ( rolesManifest2 , rolesBicep2 ) = await GetManifestWithBicep ( projRoles2 ) ;
518+ var ( rolesManifest , rolesBicep ) = await GetManifestWithBicep ( projRolesStorage ) ;
519+ var ( rolesManifest2 , rolesBicep2 ) = await GetManifestWithBicep ( projRolesStorage2 ) ;
536520
537521 var expectedRolesManifest =
538522 """
539523 {
540524 "type": "azure.bicep.v0",
541- "path": "funcapp-roles.module.bicep",
525+ "path": "funcapp-roles-my-own-storage .module.bicep",
542526 "params": {
543- "my_own_storage_outputs_name": "{my-own-storage.outputs.name}"
527+ "my_own_storage_outputs_name": "{my-own-storage.outputs.name}",
528+ "principalId": "{funcapp-identity.outputs.principalId}"
544529 }
545530 }
546531 """ ;
@@ -550,9 +535,10 @@ public async Task MultipleAddAzureFunctionsProject_WorksWithAddAzureContainerApp
550535 """
551536 {
552537 "type": "azure.bicep.v0",
553- "path": "funcapp2-roles.module.bicep",
538+ "path": "funcapp2-roles-funcstorage634f8 .module.bicep",
554539 "params": {
555- "funcstorage634f8_outputs_name": "{funcstorage634f8.outputs.name}"
540+ "funcstorage634f8_outputs_name": "{funcstorage634f8.outputs.name}",
541+ "principalId": "{funcapp2-identity.outputs.principalId}"
556542 }
557543 }
558544 """ ;
@@ -565,30 +551,21 @@ public async Task MultipleAddAzureFunctionsProject_WorksWithAddAzureContainerApp
565551
566552 param my_own_storage_outputs_name string
567553
568- resource funcapp_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
569- name: take('funcapp_identity-${uniqueString(resourceGroup().id)}', 128)
570- location: location
571- }
554+ param principalId string
572555
573556 resource my_own_storage 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
574557 name: my_own_storage_outputs_name
575558 }
576559
577560 resource my_own_storage_StorageBlobDataOwner 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
578- name: guid(my_own_storage.id, funcapp_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'))
561+ name: guid(my_own_storage.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b'))
579562 properties: {
580- principalId: funcapp_identity.properties. principalId
563+ principalId: principalId
581564 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'b7e6dc6d-f1e8-4753-8033-0f276bb0955b')
582565 principalType: 'ServicePrincipal'
583566 }
584567 scope: my_own_storage
585568 }
586-
587- output id string = funcapp_identity.id
588-
589- output clientId string = funcapp_identity.properties.clientId
590-
591- output principalId string = funcapp_identity.properties.principalId
592569 """ ;
593570 output . WriteLine ( rolesBicep ) ;
594571 Assert . Equal ( expectedRolesBicep , rolesBicep ) ;
@@ -600,60 +577,51 @@ param my_own_storage_outputs_name string
600577
601578 param funcstorage634f8_outputs_name string
602579
603- resource funcapp2_identity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
604- name: take('funcapp2_identity-${uniqueString(resourceGroup().id)}', 128)
605- location: location
606- }
580+ param principalId string
607581
608582 resource funcstorage634f8 'Microsoft.Storage/storageAccounts@2024-01-01' existing = {
609583 name: funcstorage634f8_outputs_name
610584 }
611585
612586 resource funcstorage634f8_StorageBlobDataContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
613- name: guid(funcstorage634f8.id, funcapp2_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'))
587+ name: guid(funcstorage634f8.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe'))
614588 properties: {
615- principalId: funcapp2_identity.properties. principalId
589+ principalId: principalId
616590 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe')
617591 principalType: 'ServicePrincipal'
618592 }
619593 scope: funcstorage634f8
620594 }
621595
622596 resource funcstorage634f8_StorageQueueDataContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
623- name: guid(funcstorage634f8.id, funcapp2_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88'))
597+ name: guid(funcstorage634f8.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88'))
624598 properties: {
625- principalId: funcapp2_identity.properties. principalId
599+ principalId: principalId
626600 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '974c5e8b-45b9-4653-ba55-5f855dd0fb88')
627601 principalType: 'ServicePrincipal'
628602 }
629603 scope: funcstorage634f8
630604 }
631605
632606 resource funcstorage634f8_StorageTableDataContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
633- name: guid(funcstorage634f8.id, funcapp2_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3'))
607+ name: guid(funcstorage634f8.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3'))
634608 properties: {
635- principalId: funcapp2_identity.properties. principalId
609+ principalId: principalId
636610 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '0a9a7e1f-b9d0-4cc4-a60d-0319b160aaa3')
637611 principalType: 'ServicePrincipal'
638612 }
639613 scope: funcstorage634f8
640614 }
641615
642616 resource funcstorage634f8_StorageAccountContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
643- name: guid(funcstorage634f8.id, funcapp2_identity.id , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab'))
617+ name: guid(funcstorage634f8.id, principalId , subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab'))
644618 properties: {
645- principalId: funcapp2_identity.properties. principalId
619+ principalId: principalId
646620 roleDefinitionId: subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '17d1049b-9a84-46fb-8f53-869881c3d3ab')
647621 principalType: 'ServicePrincipal'
648622 }
649623 scope: funcstorage634f8
650624 }
651-
652- output id string = funcapp2_identity.id
653-
654- output clientId string = funcapp2_identity.properties.clientId
655-
656- output principalId string = funcapp2_identity.properties.principalId
657625 """ ;
658626 output . WriteLine ( rolesBicep2 ) ;
659627 Assert . Equal ( expectedRolesBicep2 , rolesBicep2 ) ;
0 commit comments