- Yooo! Adam Saxton with Guy in a Cube. And in this video I wanna walk you through Git Integration
with Microsoft Fabric, specifically with Power BI Reports. Git Integration is actually
supported with lakehouses, notebooks, Paginated
reports, Power BI reports, and the semantic models, and I'm sure more will come later. But I want to just focus
in on how do we set up Git, how do we actually get a Power
BI report going with this from a version control perspective? Because a lot of folks had asked for source control
capabilities and this is it. So, enough of all this talking, you know we like to do
it here on Guy in a Cube. Let's do what? Let's head over to my machine. We're gonna start our journey
inside of Azure DevOps. As of the recording Of this video, the Git Integration
options that are available inside of Microsoft Fabric are leveraged through Azure DevOps Git Repos, not Git Repos that are
hosted inside of GitHub. So if that is something
that you wanna see, definitely go out to
ideas.fabric.microsoft.com and vote that up. I'm sure it will come at some point. Of note, DevOps on-premises
is not supported, so it has to be the
cloud-based version of this. All right, so I went ahead
and created a project. I've got a Git repo here, or repository, and I've already cloned
this to my local machine, so it's sitting inside of my D drive, inside of my source folder. And so that's what we're
gonna be working off of here. So the first thing I want to do here is I'm coming into Power BI Desktop and to leverage Git Integration
inside a Power BI Desktop, we have to use what's called
a Power BI Project file. And to use that, we've got to
go enable the preview feature. So we're gonna go over to preview features and you will see Power BI
Project, PBIP, save option. That needs to be selected, you hit OK, restart Power BI Desktop,
and you're good to go. This is a classic PBIX. Can't believe I just used
the word classic there, but there it is. So this is a PBIX file,
it's a single binary file. And what I'm gonna do now is I'm just gonna go
ahead and do a save as. You'll see here that you can choose PBIP, project not template. And then I'm just gonna
go and browse my devices and I'm gonna go to d:\src\GitRepo. This is where I wanna save it and I'm gonna choose save as type and I'm gonna save Power
BI Project file, PBIP. Let's go and hit save. When we go to that GitDemo folder, you'll see what it saved out here. It actually saved out a PBIP file. We've got our reports and
we've got our data set or the semantic model. So these items are now there and inside of there we've got JSON files, which are just text files, which we can apply source control to. This is on my local machine, it's not up in the cloud yet. So if you go to Azure DevOps
and the Git repo there, you're not gonna see it there. So how do we get it there? We got to get it into Azure DevOps first, then we can play around with
it with Microsoft Fabric. We have to do what's
referred to as a push. Ideally, what you would do is
do a branch as part of this. I'm in the main branch right
now, so you'll see that because of the yellow color in main. And if I do get status, you'll
see here that it's saying, "Hey, there's some items here that we need to add to commit." I'm actually going to create
a new branch for this, I think that's cleaner. So I'm gonna do git
checkout -b "initialfile" so this is gonna create a
branch called initialfile and we're gonna go over to that branch. So now you'll see the
yellow change to initialfile if we do get status again. We still have our items here. So let go ahead and we're
gonna add these items and do a commit. I know this is a lot of
stuff from a Git perspective. You may not be familiar with Git, but you should learn it. In this case, the way Git tracks things is through what's called a commit. And so what I did just now
is I added files to a staging and then I added that
staging to the commit. So now I've created a commit
that is part of that repo. It's still all on my local machine. So we got to get this up to
the actual cloud, as it were, so Azure DevOps, right? And so this is done by way
of what's called a push. And so I am going to
push this to the cloud and then from the cloud
I can do what's referred to as a pull request to get
it from one branch to another. Because I just created the branch, it's giving me a error, basically says it doesn't
know where to put it to. From this branch's perspective, it doesn't know anything
about Azure DevOps so I need to set that up. And really you can just copy
and paste this line here and now it's pushed
everything up to Azure DevOps. You can see that by the line, the guyinacube.visualstudio.com/GitDemo and if I do get status again, everything's up to date,
so we're good to go. So now if we go back to Azure DevOps and we refresh, we don't see anything, that's 'cause we're in the main branch. And so let's go over to initialfile and now we'll see items are here. So now we need to get
these items into main and then we can continue. So I'm gonna go and create a pull request. If you've got multiple
people working on things, I've just found as a best practice, the way that I can quickly visualize which pull requests are mine is I just add a emoticon in front of it. So I do a fist bump and then
let's do create, it's there. So I will complete,
which will do the merge and that is taking the files from initialfile branch into main. If we go back to files,
we go back to main. And now we see these items inside of main. Poof, that was a lot. We haven't even gotten
to the fabric stuff, I know, hang in there. And if you wanna learn more
about Git go to git-scm.com. Also you can go to GitHub and there's a lot of great information out on GitHub as well. These are common practices
for doing things. Okay, let's go to the fun stuff, let's go to Microsoft Fabric. So I've got two workspaces that are here. We've got Git Dev, I'm gonna treat this as my development workspace. And then I've got another one called Git. And so that'll be the
production workspace. So let me just go ahead and pin Git Dev. All right, so we're gonna
go between these two. So the first is Git Dev. So we're gonna go to workspace settings and we're gonna go to Git integration. And we'll see that I've
got my Azure DevOps piece and we're gonna do guyinacube, we'll do project Git repo is GitDemo. And now we've got a choice
here from a branch perspective. What do we want to actually create? For this case, I'm just
gonna go ahead, log this, and I'm gonna do a branch
that's assigned specifically to a given workspace. You can do different repos for different workspaces themselves. You can do different
branches for workspaces. A lot of different ways
you can segment this and to control what's going on. I'm gonna go and create a branch
that's called Dev and Prod. And then the workspaces will be assigned to those different branches. All right, so I'm going and
created those two branches with inside of Azure DevOps,
or you can do it right here. And so I'm gonna select the Dev branch and you can even go a step further and choose a folder within a branch. Like I said, lots of options here. So figure out how you want
to organize yourself here and then you can go forward and do that. So for Git folder, I'm
not gonna do anything. So I'm gonna do connect and sync and right now it's syncing the items from the Git branch into my workspace. So we should see the Power BI report and the semantic model, life is good. Now here's the problem. When you use Git integration for this, wamp, wamp, no data. It's not gonna sync the data, it just syncs the schema,
right, the model definition. And so you've got to go through now and set up the different
data as part of it and get the model refreshed and then the report
will work at that point. Just like a good cooking show again, if we go into the report,
bam, we've got data. All right, Adam, now what? You've got the report and
data set from a Git repo, we set up the data, we
refreshed the model, our report's working, but
this is development, right? How do I translate this to prod? We can work with the report and the model either on-premises, so like on your working machine itself through Power BI Desktop, or you can actually
work with it in the web and those items will all
be synced back and forth. So, first off, I'm gonna go
to Power BI Desktop here, and we're in the file. So I'm just gonna say new page. And let's just go add
internet sales amount. We'll change it to a bar
chart and we'll add month. So I'm just adding a
new page called page one and we've added a visual on there, right? So I'm gonna go and save that. Remember I did that locally, right? So we got to go back
up to the cloud, right? So we got to do the whole push
pull request, all that jazz. So if I do get status, it's gonna show that I've
got a modified item here. Now I wanna make sure I'm
doing this in the Dev branch because that's what's assigned to the given workspace itself. Now, from a Git perspective, again, lots of different ways you can do this. I could actually set up a working branch where these are my changes and I get those pumped into Dev or I can go to Dev directly. So you can see here, I'm actually in a branch
called workingdev. And then we'll do a pull
request over to the Dev branch that's aligned to the workspace. I know it's a lot, I'm
sorry, bear with me here. And so if we do get status, you'll see that a report file has been modified. So we'll do the same thing we did before. So I'm gonna add it to a staged area and then I'm going to
actually commit the change. And now that is part of a commit. So now what I can do is I can do Git push and that sends it up to the cloud. Now let's go back to the repo. So if we go to workingdev,
we'll see the changes, I'll do a pull request and we're gonna put that into Dev. Create, and then we'll complete it. Complete merge, bam, it's merged. And so now if we go back to Dev, which is what our workspace is aligned to, we should see the actual change. So now it's telling us, "Hey,
there has been a change." Microsoft Fabric is telling you, "Hey, there's an updated commit that's sitting in Azure DevOps that's not represented
inside of your workspace. What do you want to do with it?" And so what we want to do is we wanna pull those changes in. And so it's gonna do this with what's called a synchronization. So if we click on source
control here in the Dev branch, we'll see, hey, there's an
item here that's been updated and you'll see it here also. It says update required. So let's just say update all, all right? And if we go into the report
now, we now see that new page and we see the chart that we put on instead of the overview page. So I did some changes
locally, put those up into Git and then updated the workspace with the Git items and everything's great. So now let's do the other part of this. What if I edit it in the web? I can just go in and edit the report and it'll take these changes. But before I do that, let's actually get this set up into the actual Prod branch itself. So let me go over to the
Git workspace settings. I'm gonna set this up
like I did the other one, but in this case I'm gonna
choose the Prod branch and we're gonna connect and sync, right? These are synchronized, but now I got to set up the data set 'cause the report doesn't
work yet, so hang on. All right, and our items have been synced, the report is there,
everything works, life is good. So now one thing in that
report in the Prod workspace, the new page I created is not there because it only exists in Dev. I haven't moved it over to Prod yet. So I need to do a pull request
on the Azure DevOps side to get it from Dev to Prod, at which point the Prod
workspace will pick this up. So let's go back here and we're gonna go over
to the pull request tab and I'm gonna say new pull request. And what I wanna do is, I
want to take whatever's in Dev and I wanna move it to Prod. Remember I like my little
emoticon, new page to prod, and then we'll hit create
and then we'll complete. And if I come back to Power BI, we're in our production workspace and we should see an update come here from a source control perspective. And there it is, we've got a report item. So we'll say update all. And now if we go into our report, we should see the new
page here, which is great. But oh, oh, I didn't mean
to push that into Prod, what do I do? So now let's go and back into Dev, we'll remove that page
and see what happens. And we'll do this all
from the web browser too. So we're not gonna go to Power BI Desktop. So I'm gonna move over to my Git Dev and we're gonna go into the report. Let's just say we're gonna go to edit. We're gonna delete this page and we'll come back to our overview page, and then file and save. So that is saved now. And you'll see that we have
an uncommitted change here. So this is similar to what happened when we did it On-Prem, right? So if we made a change in
Desktop, we did get status. It would say, "Hey, you got
some uncommitted items here, you need to do something with them." And so we'll have to do the same thing. We've got to stage them, commit them, and then get a pull request
to get them over to Prod. So let's go to source control and we'll see which items do we want. So we want the report and what
commit message do we have? So this is kind of doing
the staging and commit at the same time. And so we'll say remove page,
and then we'll do the commit and bam, we've made that commit itself. And so this has actually already pushed it into that Dev branch. Now what we need to do is come back to this pull request page and
we'll say new pull request. Make sure you get the branches right. So we're gonna go Dev to Prod and we're gonna do that, remove
the page, create, complete. And when we go back to
our production workspace, we should see the update
there, that's great. And we're gonna update all of the items, which in this case is
just the report page. If we go back into the
report now, you'll notice that extra page I added is now gone. And you can go back and forth. You can do the webpage, you can do this from Power BI Desktop. This is a Git repository, right? So it's a essentially managed item that multiple contributors can put into, and it is a concept of commits and rollbacks, pull requests, pushes. All of these things exist with
inside of this environment. Let me know in the comments if
you played around with this, do you have plans to implement this into your DevOps experience? Also, I'll have links
down in the description to more information about this. Thank you so much for watching. Keep being awesome and we'll
see you in the next video.