Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sipati
Microsoft Employee
Microsoft Employee

Update Azure Blob Storage credentials using REST API

I have a PowerBI report, and I want to update Accountname and accountkey using Rest API. I found a way to use parameter as an account name, but didn't find anything on AccountKey. 

Any help regarding this? Is it possible to update it using this-
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updatedatasources
OR-
https://docs.microsoft.com/en-us/rest/api/power-bi/datasets/updateparameters

In Any way?

5 REPLIES 5
baden27
Regular Visitor

Hi, 

 

I hope you can help me!

How can i update my azure blob credentials in powerbi with SA access api (rest api)

I keep getting a bad request. 

 

 


foreach($datasource in $datasources) {
  Write-Host $datasource.DatasourceType
  $gatewayId = $datasource.gatewayId
  $datasourceId = $datasource.datasourceId
  $ApiUrl = "https://api.powerbi.com/v1.0/myorg/gateways/$gatewayId/datasources/$datasourceId"


  Write-Host "gatewayId $gatewayId"
  Write-Host "datasourceId $datasourceId"
  Write-Host "Patching url  $datasourePatchUrl"


  #Build the request body
  $ApiRequestBody = @"
 
 
  {
    "credentialDetails": {
      "credentialType": "Key",
      "credentials": "{\"credentialData\":[{\"name\":\"key\", \"value\":\"MYKEY......\"}]}",
      "encryptedConnection": "NotEncrypted",
      "encryptionAlgorithm": "None",
      "privacyLevel": "Private"
    }
  }
"@


 Invoke-PowerBIRestMethod -Url "gateways/$gatewayId/datasources/$datasourceId" -Method PATCH -Body $ApiRequestBody | ConvertFrom-Json -Verbose
 Write-Output "Credentials for data source ""$DataSourceId"" successfully updated..." `n

}
Jayendran
Solution Sage
Solution Sage

Hi @sipati ,

 

Currently you couldn't able to use either parameters/ update datasource api to dynamically change the account key from the azure blob.

 

The only workaround for this, you have to use a gateway. 

 

  • Parameter your azure blob storage account name
  • Configure both azure storage blobs in the gateways
  • Update the parameter to change the account name
  • Then automatically the report will use the other data source in the gateway.

Hello @Jayendran ,

 

Any reason why it is not possible to update the Credentials for the Blob storage?


Becaue based on the MSFT documentation link :

https://docs.microsoft.com/en-us/rest/api/power-bi/gateways/updatedatasource#basic-credentials-examp...

 

we can patch the Cred with Key type :

key.PNG

 

So cant we use this powershell to update the cred:


Invoke-PowerBIRestMethod -Url "gateways/$($BounGateway.value.gatewayId)/datasources/$($BounGateway.value.id)" -Method PATCH -Body $Body | ConvertFrom-Json

where the body is the above JSON format .

 

 

Thanks




----------------------------------------------------------------------------------------------
Nandan Hegde (MSFT Data MVP)
LinkedIn Profile : www.linkedin.com/in/nandan-hegde-4a195a66
GitHUB Profile : https://github.com/NandanHegde15
Twitter Profile : @nandan_hegde15
MSFT MVP Profile : https://mvp.microsoft.com/en-US/MVP/profile/8977819f-95fb-ed11-8f6d-000d3a560942
Topmate : https://topmate.io/nandan_hegde
Blog :https://datasharkx.wordpress.com

Good Morning... I can update the credential, but the records are not updating Did you succeed with this feature?

Hi @NandanHegde ,

 

Thanks for correcting me . I can confirm using update datasource you can update the keys.

 

Good catch ! Sorry for the wrong information 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.