Posts Tagged ‘CLI’

[Step by Step] Power Apps portals | Version Control website using Power Platform CLI

In this article, lets see how to version control the Portal website components using Power Platform CLI Portal commands.

What is Version Control

  • Version control, also known as source control, is the practice of tracking and managing changes to software code.
  • Version control software keeps track of every modification to the code in a special kind of database. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members.

Lets start working with Portal CLI with prerequisites.


Before we jump on to CLI, lets see how portal components can be edited from maker portal.

Edit Portal Website from Maker Portal

Once your Portal application created

  • Click on the portal app.
  • You will be redirected to your portal website as shown below.
  • If you notice, portal website is collection of many components (i.e., Web Pages, Lists, Files, etc…). You can edit the web site by using ‘Edit’ option directly from maker portal.
  • You will be redirected to Portal editor and can edit the components.

Challenges with editing Website directly from Maker Portal

As detailed in above section, you can edit the website directly from Maker Portal but at the cost of following challenges.

  • Its not version controlled. Meaning, if I want to revert a file with content from last stable release, it not possible with out version control.
  • As a Pro developer, you would feel comfortable editing webpage as html file than in the portal editor.

Use Power Platform CLI with portals

Lets see how we can solve versioning using CLI.

  • Open a new ‘Terminal’.
  • As a first step, you need to connect to your Dataverse environment by executing following command.
    • pac auth create -u {Environment_url}
  • Get the list of available Portals by executing following command.
    • pac paportal list
  • Copy the ‘WebSiteId’ as highlighted above.
  • Now download the website components using following command.
    • pac paportal download –path [PATH] -id [WebSiteId]
  • Website contents gets downloaded and saved locally as below.
  • Now, open this folder using VSCode and open the components.
  • Lets go ahead and edit the ‘Home’ web page content.
  • Upload the modified website components using following command.
    • pac paportal upload –path [Folder-location]
  • The upload only happens for content that’s been changed. In the above example, since the change is made to a webpage, content is uploaded only for the adx_webpage table.
  • Now, lets refresh the portal website and you should see the modified text.
  • If you dont see the changes, you can clear the server-side cache as below.
    • Navigate to the URL as follows: <portal_path>/_services/about.
    • Select Clear Cache.

Advantages of CLI for portals development

  • We can commit the website components to any of the version control tools like Azure DevOps, GitHub.
  • We can now use offline-like capability for portals customization by making changes to the portals content. And once all customizations or changes are saved, upload them to the portal.
  • Helps integrate seamlessly with any source control tools, such as “git”
  • Easily set up CI/CD pipelines


  • Portals support for Power Platform CLI is limited to the tables listed here.


Categories: Portals Tags: , ,

Power Platform CLI | Authenticate environment using device code

For unversed, Microsoft Power Platform CLI is a developer CLI that empowers developers and ISVs to perform various operations related to environment lifecycle, authentication, and work with Dataverse environments, solution packages, portals, code components, and so on.

In this blog post, lets see how to connect to an Environment using Power CLI ‘Device Code’ authentication option.

Using CLI:

  • Open Command Prompt.
  • Execute pac command to make sure the Power Platform CLI is installed on your machine. You get following screen, if CLI is already installed.
  • If not installed, Download and install Microsoft Power Platform CLI.
  • Now to connect to Power platform environment, we can use following pac auth create command by passing either Username & Password or ApplicationID & ClientSecret combination.
pac auth create [--name] [--kind] [--url] [--username] [--password] [--applicationId] [--clientSecret] [--tenant] [--cloud] [--deviceCode]
  • We can also authenticate using ‘deviceCode’, which I will explain in next section.

Authenticate using Device Code:

Now we can also authenticate to an environment by generating a ‘Device Code’ as mentioned in steps below.

  • From console, run following pac auth create command
pac auth create --url https://{your environment} -dc
  • You would get a notification with ‘Device Code‘, “To sign in, use a web browser to open the page and enter the code RXXXXZ to authenticate.
  • Complete the sign in by providing your credentials.
  • You will get following message post successful authentication.
  • Now you can close the browser and good to start executing pac cli commands from console.

Key Points:

  • Currently, Microsoft Power Platform standalone CLI is supported only on Windows 10 and Windows 11.
  • Power Platform Tools for Visual Studio Code is available on Windows 10, Windows 11, Linux, and MacOS.


Categories: PowerApps Tags: , , ,