Skip to content

Add Assigning an Identity to a Module Support - #17150

Merged
Tate Smalligan (tsmallig33) merged 7 commits into
mainfrom
tasmalligan/AssignManagedIdentityToModule
May 15, 2025
Merged

Tate Smalligan (tsmallig33) merged 7 commits into
mainfrom
tasmalligan/AssignManagedIdentityToModule

Conversation

@tsmallig33

@tsmallig33 Tate Smalligan (tsmallig33) commented May 14, 2025 •

Copy link
Copy Markdown
Member

Description

Add identity object to modules. Will add builtin functions later to convert params to identity object: az.noneIdentity(), az.systemAssignedIdentity(), az.userAssignedIdentity(input array), az.systemAndUserAssignedIdentity(input array)

Example Usage

Bicep

param identityId string

module mod './module.bicep' = {
    identity: {
        type: 'UserAssigned'
        userAssignedIdentities: {
            '${identityId}': {}
        }
    }
    name: 'mod'
    params: {
        keyVaultUri: 'keyVaultUri'
        identityId: identityId
    }
}

ARM Template

"mod": {
      "type": "Microsoft.Resources/deployments",
      "apiVersion": "2022-09-01",
      "identity": {
        "type": "UserAssigned",
        "userAssignedIdentities": {
          "[format('{0}', parameters('identityId'))]": {}
        }
      },
      "name": "mod",
      "properties": {
          ...
      }

Checklist

Microsoft Reviewers: Open in CodeFlow

@tsmallig33 Tate Smalligan (tsmallig33) changed the title Assign Identity to Module Support Add Assigning an Identity to a Module Support May 14, 2025
@github-actions

github-actions Bot commented May 14, 2025 •

Copy link
Copy Markdown
Contributor

Test this change out locally with the following install scripts (Action run 15053031481)

VSCode
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-vsix.sh) --run-id 15053031481
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-vsix.ps1) } -RunId 15053031481"
Azure CLI
  • Mac/Linux
    bash <(curl -Ls https://aka.ms/bicep/nightly-cli.sh) --run-id 15053031481
  • Windows
    iex "& { $(irm https://aka.ms/bicep/nightly-cli.ps1) } -RunId 15053031481"

@github-actions

github-actions Bot commented May 14, 2025 •

Copy link
Copy Markdown
Contributor

Dotnet Test Results

    78 files   -     39      78 suites   - 39   35m 28s ⏱️ - 18m 22s
12 146 tests  -      6  12 146 ✅  -      6  0 💤 ±0  0 ❌ ±0 
28 054 runs   - 14 001  28 054 ✅  - 14 001  0 💤 ±0  0 ❌ ±0 

Results for commit da134a7. ± Comparison against base commit ea18fd2.

This pull request removes 1883 and adds 649 tests. Note that renamed tests count towards both.

		nestedProp1: 1
		nestedProp2: 2
		prop1: true
		prop2: false
	1
	2
	\$'")
	prop1: true
	prop2: false
…
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
�Ի
�0\u0014\u0006��>E�\u0003���
\u001d\u0004\u0007+R\u0005�U�
X�U�
\u0005_�t\u0010�\u0016�^\u0004�9\u0007r��\u0007�{]��NLQ"ʄ�\u0011�\u001b�$��
�\u0015 �
\u0003���\u0000���IZ<�J\u0017v�1��At\u000eu�f&$�+�(�\u0001�\u0001Ut�f�v\u0000�uu	�<15����iϺڧ>����~�]ѷ�c�\u0001\u0011�\u0010N%S\u0002`)x��Q2����zQ|\n��is���\u0002�\u001fx�\u001c�q��\u0000\u000f\u0002"$\u0000\u000c\u0000\u0000,"'7' is an invalid end of a number. Expected a delimiter. Path: $.INVALID_JSON | LineNumber: 0 | BytePositionInLine: 20.")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
��K
�0\u0010\u0006�=EO�f���E�.�BЂ\u000f�J�҂xw����Mm\u0005�-g\u00182I�i��î�Dzi)\u0017R�̍\u0005
q�\u001e�\u0004\u0002��\u0011�e��l�}�\u0011]�m\u0013VY�\u001f�Mf��*\u000b��\u0002
E4J��&�\u000e�=�n֟��]]�;zik\u0017\u0007����/��z��o=ѧ�3�	H\u0006�\	�!� b�\u0017�����X{�$I�d
O�3\u00067\u0000\u000c\u0000\u0000,"The path: index.json was not found in artifact contents")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000
��K
�0\u0010\u0006�=E�\u0001ҤyY�{7�\u001b\u000f\u0010�\u0011+���B@���Bܴ��C0�23�I�\u001f\u0012�݂ɠnHĥ
	\u001a\u001bu�\u0010��\u001d&4b��"��T\u0008a;�$=�Mkj7�\u001c{��h�M�\u0017�0-4�\u0011\u00171�i����ҡ\u001a�qe�s��\u0019Xrine�^\u000c�/}Lo������o��\ &)c"R\KD�t?\u0002³d�������\u0004[A�B���\u0008u��'sm��l��y�t^��p�\u0000\u000c\u0000\u0000,"Value cannot be null. (Parameter 'source')")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003�Խ
�0\u0010\u0007��>E�\u0001��%i��Ap�"U\u0010\%؀\u0015��V(�\uda58\udcf8���C0�1wp\u0017�?���ratj�9���OIۘ\u0015\u0008Q{^\u0001�\u0008�7F��B\u0012╭oR�\u0017�nW�c�\u000f���Ev6\u0011(�8GĀ�\u000c\u0015J\u001c�ڡ�\u0006\u0013曆c�]RS�S~�T������4��_w3�埡  \u0019��\u0000\u0019\u0012\u0016H�m�{����9���l\u0015����:\u0019O=�\u0003\u000f���8�ӽ\u0017XV��\u0000\u000c\u0000\u0000,"'7' is an invalid end of a number. Expected a delimiter. Path: $.INVALID_JSON | LineNumber: 0 | BytePositionInLine: 20.")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003��K
�0\u0010\u0006�=E�\u0001Ҽ��н\u001b��\u0007��\u0015[K\u0013� ��t!nZ��!�o�\u0019�	�O�i�`rh,\u0011LИ��QOI���a���\u001bET'�#���7�q��4~�9f� ��qE	)�R\u000b�9W�����|)\u001b(�5��;�E�CK.�Vu��@���\u000c�}.8݌o����?��I�8刪Ŀ <K&�<�\u000f\u001c\u001d*hk�\u001c�;(��D\u001b|2W\u000bϥw\u000b� \u0008��\u0002\u000c*2�\u0000\u000c\u0000\u0000,"Value cannot be null. (Parameter 'source')")
Bicep.Core.IntegrationTests.AzTypesViaRegistryTests ‑ Bicep_compiler_handles_corrupted_extension_package_gracefully (\u001f�\u0008\u0000\u0000\u0000\u0000\u0000\u0000\u0003���
�0\u000c\u0007��\u0014>AM������^�l�>�\u000e�L\u0018{���`\u0007e\u0017���wl\u0008I	���l_��P6�T� �bn\u0010ḍ�\u0003�(м�\u0000�\u0019�H��7\u0019ѵ�6a�%f� �&֟�2G�F)"ҒA1!oBm?Y��j�1����7'�m톆j�a�F�����\u0019��\u000f@\u00025 2e\u0004\u0018\ud9fd\ude05�/��?�����\u0006Q\u0014E�\u001a�.�cy\u0000\u000c\u0000\u0000,"The path: index.json was not found in artifact contents")
Bicep.Core.IntegrationTests.DirectResourceCollectionTests ‑ DirectResourceCollectionAccess_NotAllowedWithinLoops ("output loopOutput array = [for i in range(0, 2): {
  prop: map(containerWorkers, (w) => w.properties.ipAddress.ip)
}]")
Bicep.Core.IntegrationTests.DirectResourceCollectionTests ‑ DirectResourceCollectionAccess_NotAllowedWithinLoops ("resource propertyLoop 'Microsoft.ContainerInstance/containerGroups@2022-09-01' = {
  name: 'gh9440-loop'
  location: 'westus'
  properties: {
    containers: [for i in range(0, 2): {
      name: 'gh9440-w1c-${i}'
      properties: {
        command: [
          'echo "${join(map(containerWorkers, (w) => w.properties.ipAddress.ip), ',')}"'
        ]
      }
    }]
  }
}")
Bicep.Core.IntegrationTests.DirectResourceCollectionTests ‑ DirectResourceCollectionAccess_NotAllowedWithinLoops ("var loopVar = [for i in range(0, 2): {
  prop: map(containerWorkers, (w) => w.properties.ipAddress.ip)
}]")
Bicep.Core.IntegrationTests.Emit.ParamsFileWriterTests ‑ Params_file_with_no_errors_should_compile_correctly ("
using 'main.bicep'

// involves all syntax
param myParam = {
  arr: [
    {
      a : 'b'
    }
    {
      c : true
    }
  ]
  name: 'complex object!'
  priority: 3
  val: null
  obj: {
      a: 'b'
      c: [
          'd'
           1
      ]
  }
}","
{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "myParam": {
      "value": {
        "arr" : [
          {
            "a" : "b"
          },
          {
            "c" : true
          }
        ],
        "name" : "complex object!",
        "priority" : 3,
        "val" : null,
        "obj" : {
          "a" : "b",
          "c" : [
            "d",
            1
          ]
        }
      }
    }
  }
}","
param myParam object
")
…

♻️ This comment has been updated with latest results.

@shenglol

Copy link
Copy Markdown
Contributor

I think we should hold off on merging the PR until the back-end change is deployed; otherwise, users who discover and use the new identity property on a module will run into errors. Alternatively, we could guard the property with a feature flag to allow us to merge the changes now.

@tsmallig33

Copy link
Copy Markdown
Member Author

I think we should hold off on merging the PR until the back-end change is deployed; otherwise, users who discover and use the new identity property on a module will run into errors. Alternatively, we could guard the property with a feature flag to allow us to merge the changes now.

Updated to add feature flag moduleIdentity which will update the module api version to 2025-04-01 when enabled.

@tsmallig33
Tate Smalligan (tsmallig33) deleted the tasmalligan/AssignManagedIdentityToModule branch May 15, 2025 18:58
@mumian

Copy link
Copy Markdown
Contributor

Module identity is an experimental feature. Wait for its official release before adding documentation.

@mumian

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants