I have created a service principle in Azure AD B2C and want to upload TrustFrameworkExtensions.xml
file to it using Set-AzureADMSTrustFrameworkPolicy
powershell cmdlet in GHA. Everything in this works for me except the last line. I get an error Set-AzureADMSTrustFrameworkPolicy
is not know cmdlet even though I am able to successfully import Powershell AzureADPreview
module without any issues. I am pulling my hair out to figure this out.
Also note this works on my laptop. But i am getting an error while running it in github actions. I am running windows powershell
this is the error:
Set-AzureADMSTrustFrameworkPolicy : The term 'Set-AzureADMSTrustFrameworkPolicy' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify
that the path is correct and try again.
At D:\a\_temp\e4c3721f-2770-44f1-897e-b9434474d966.ps1:23 char:1
+ Set-AzureADMSTrustFrameworkPolicy -Id B2C_1A_TrustFrameworkExtensions ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Set-AzureADMSTrustFrameworkPolicy:String) [], ParentContainsErrorRecord
Exception
+ FullyQualifiedErrorId : CommandNotFoundException
Error: Process completed with exit code 1.
This is the code:
run-script:
runs-on: windows-latest # Run on Windows for PowerShell compatibility
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Azure login
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- name: Upload Files to Azure AD B2C
run: |
Install-Module -Name AzureADPreview -Scope CurrentUser -Force -AllowClobber
Import-Module AzureADPreview
if (Get-Module -Name AzureADPreview -ListAvailable) {
Write-Host "AzureADPreview module is installed."
} else {
Write-Host "AzureADPreview module is not installed."
}
az login --service-principal --username $service-principal-clientId --password $service-principal-password --tenant $tenantId --allow-no-subscriptions
$aadToken = az account get-access-token --resource-type aad-graph | ConvertFrom-Json
$graphToken = az account get-access-token --resource-type ms-graph | ConvertFrom-Json
Connect-AzureAD -AadAccessToken $aadToken.accessToken -AccountId $service-principal-clientId -TenantId $tenantId -MsAccessToken $graphToken.accessToken
Set-AzureADMSTrustFrameworkPolicy -Id B2C_1A_TrustFrameworkExtensions -InputFilePath .\Templates\TrustFrameworkExtensions.xml
shell: powershell
```