Forum Discussion

MohitMakhija199's avatar
MohitMakhija199
Microsoft Employee
2 years ago
Solved

Unable to get Token for deployment using powershell.

I am trying to deploy notebooks, lakehouses and powerbi reports using the fabric rest api : Items - Create Notebook - REST API (Notebook) | Microsoft Learn I saw some samples in the github repositor...
  • KevinChant's avatar
    2 years ago

    I took a slightly different stance on this, which might be able to help you out.

     

    For one pipeline I commented out the connect-azaccount in the PowerShell script and connected to it outside of the script instead using a service principal account as below:

     

                      $SecureStringPwd = ConvertTo-SecureString $(servicePrincipalKey) -AsPlainText -Force
                      $pscredential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $(servicePrincipalId), $SecureStringPwd
                      
                      Connect-AzAccount -ServicePrincipal -Credential $pscredential -Tenant $(tenantId)
     
    I then ran the script with the commented out line afterwards.
     
    Let me know if that helps.