Search code examples
azureterraformterraform-provider-azureazure-service-principal

Terraform : How do I set the value of accessTokenAcceptedVersion to 2 for a Azure Service Principal?


I have used the below terraform script to provision the service principal in Azure

resource "azuread_application" "app" {
  display_name = "app"
  owners       = "xxxx"
}

resource "azuread_service_principal" "principal" {
  application_id = azuread_application.app.application_id
}

I could see the manifest mentioned below

enter image description here

However, I want to set the value of accessTokenAcceptedVersion to 2 using the terraform.

How do I set the value of accessTokenAcceptedVersion to 2 for a Azure Service Principal?


Solution

  • However, I want to set the value ofaccessTokenAcceptedVersion to 2 using the terraform.

    Unfortunately, Terraform does not support changing the value ofaccess_token_issued_version in the Application registration. Follow the document to check the arguments are supported in Terraform.

    Alternatively, you can use Microsoft Graph commands to change the access_token_issued_version to 2.

    Connect-MgGraph -TenantId "TenantID" -Scopes "Application.readwrite.all"
        Import-Module Microsoft.Graph.Applications
        $AppId="Azure AD Application ID"
        $paramets = @{
            Api = @{
                RequestedAccessTokenVersion = 2
            }
        }
        Update-MgApplication -ApplicationId $AppId -BodyParameter $paramets
    

    Once the above code is run ,AccessTokenVersion has been updated successfully.

    enter image description here

    Reference: Terraform azuread_application seems to be missing arguments by 4c74356b41