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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
SandMonster
Frequent Visitor

Automate publishing reports process creating an azureDevOps pipeline???

Hi everyone, I am quite new using powerBi and quite new to Azure DevOps as well, does anyone know whether is possible to automate the report's publishing process, more specific, is it possible to create a pipeline task in azure devops that takes the pbix file from our repo located in azure devops, publish it to powerbi web and email a list of people?? I read about this extension called Power Bi Actions, but I haven't found really much info about the usage of this extensions and there is little to no examples of how to use it. sorry if this is the wrong topic.

 

Thanks in advance

3 REPLIES 3
Anonymous
Not applicable

Hi SandMonster, the answer is yes and we are trying (note: trying) to implement this. We are using Power BI Action and you're right, there isn't too much information on it. We have come across an issue where 2FA has been enforced in our company and Power BI Action was originally using my credentials to run, but it cannot do this with 2FA. We now need to understand if we can set up a service account. There just isn't much documentation around.

 

There are the Power BI REST APIs: https://docs.microsoft.com/en-us/rest/api/power-bi/

 

I am thinking that this may be the way to go. I'm not the technical person on this in our business but trying to find if there is documentation on how to do this.

 

For Power BI Action, the instructions on the Marketplace were helpful: https://marketplace.visualstudio.com/items?itemName=maikvandergaag.maikvandergaag-power-bi-actions 

 

I appreciate that doesn't answer your question, but I want the conversation to start rolling so we can solve this.

 

Not sure if this will help, but this is the auth code I use in an Azure Function to log into PowerBi with a service account

				TokenCredentials tokenCredentials = new TokenCredentials(await GetUserToken(log), "Bearer");
				log.Info(tokenCredentials.CallerId, (string) null);
				using (PowerBIClient powerBiClient = new PowerBIClient(new Uri("https://api.powerbi.com/"), (ServiceClientCredentials) tokenCredentials, Array.Empty<DelegatingHandler>()))
				{
				  //code
				  return req.CreateResponse(HttpStatusCode.OK);
				}
        
public static async Task<string> GetUserToken(TraceWriter log) { string password = Environment.GetEnvironmentVariable("sa_password"); //linked to keyvault string clientId = Environment.GetEnvironmentVariable("clientId"); string user = Environment.GetEnvironmentVariable("sa_user"); AuthenticationContext _authContext = new AuthenticationContext("https://login.microsoftonline.com/<TENANT ID>"); var oauthEndpoint = new Uri("https://login.microsoftonline.com/<TENANT ID>/oauth2/token"); using (var client = new HttpClient()) { var result = await client.PostAsync(oauthEndpoint, new FormUrlEncodedContent(new[] { new KeyValuePair<string, string>("resource", "https://analysis.windows.net/powerbi/api"), new KeyValuePair<string, string>("client_id", clientId), new KeyValuePair<string, string>("grant_type", "password"), new KeyValuePair<string, string>("username", user), new KeyValuePair<string, string>("password", password), new KeyValuePair<string, string>("scope", "openid"), })); var content = await result.Content.ReadAsStringAsync(); var credential = JsonConvert.DeserializeObject<OAuthResult>(content); return credential.AccessToken; } } class OAuthResult { [JsonProperty("token_type")] public string TokenType { get; set; } [JsonProperty("scope")] public string Scope { get; set; } [JsonProperty("experies_in")] public int ExpiresIn { get; set; } [JsonProperty("ext_experies_in")] public int ExtExpiresIn { get; set; } [JsonProperty("experies_on")] public int ExpiresOn { get; set; } [JsonProperty("not_before")] public int NotBefore { get; set; } [JsonProperty("resource")] public Uri Resource { get; set; } [JsonProperty("access_token")] public string AccessToken { get; set; } [JsonProperty("refresh_token")] public string RefreshToken { get; set; } }

 

 

Hi everyone, just as an update in case anyone is still interested in this topic, 

I have been working with this:

https://docs.microsoft.com/en-us/azure/devops/pipelines/tasks/utility/http-rest-api?view=azure-devop...

which is basically an agentless job that creates task in a pipeline, this task is used as the name says, to invoke generic rest apis, I have made some basic calls to powerbi's rest api and they work, I haven't had any success with pipeline the task though, this is because the documentation is quite poor and as you may imagine, specific examples are innexistent and being really honest I have zero experience with pipelines/yaml, so, still learning... anyhow I hope someone with more experience than me finds this useful,  this is what I've got so far in yaml, I know it's not much, but I hope it serves as a clue for someone. Anyhow, before doing this, you'll need to create a service connection in your devops Project Settings>Service Connections, Create new Generic service Connection

image.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.