Skip to main content
  1. Posts/

Getting Started with Power Fx

2 mins· loading · loading ·
Will Wright
Power Fx Power Platform CLI VS Code Power Fx
Will Wright
Author
Will Wright
A powerful, lightweight theme for Hugo built with Tailwind CSS.
Table of Contents

Getting started with Power Fx
#

The following allows you to start using Power Fx within in the context of a terminal window, much like PowerShell. The guide talks through installing the CLI, adding an authorisation profile and finally connecting to the environment in which to run the Power Fx.

Commands such as Collect and Remove will add and remove data from the tables so use with caution

Installing the Power Platform CLI
#

Installing the Power Platform CLI (aka pac) in VS Code is a prerequisite for this guide.

  1. Click the extensions icon on the far left of the VS Code console
    Image of completed canvas app
  2. Once the extensions have loaded search for ‘Power Platform Tools’
  3. Click the Install button highlighted

Setting up Authorisation
#

To access environments they need to be authorised, this is done simply in the terminal window. As the CLI is now installed new commands are available all prefixed with ‘pac auth’. Using ‘pac auth create’ allows creation of a new authorisation profile for the specified envionment by using the –environment parameter. The paramter can be supplied as an environment Id, as below. There are ways of connecting, but I have found guid or the environment url are the most reliable.

The following command allows the creation of an authorisation profile linked to the environment with an id of 11111111-2222-3333-4444-555555555555

pac auth create --environment 11111111-2222-3333-4444-555555555555

Once the command has been entered, a credentials prompt will pop. The crednetial to connect to the evironment will need to be added.

N.B. During testing I found, once a connection to an environment in a tenant has been created, that profile can be used to connect to other environments in that tenant.

The command below lists all authorisation profiles which have been set up, once run it will display all profiles, note the index number. pac auth list

Image of completed canvas app

To switch to different profiles another command can be used, this will make it clear as to why the index is important.

pac auth select --index 2

The command when run, switchs the profile to the chosen index.

Connecting to an Environment
#

Now the correct profile has been selected, the next command connects to the environment specified again by the –environment parameter. It will the

pac power-fx repl --environment 11111111-2222-3333-4444-555555555555

Image of completed canvas app

From the image above Power Fx code has been added to show the date


Related

Get the SSPList Id and termSetItem Id
1 min· loading · loading
Will Wright
Power Automate SharePoint Flow Term Store Managed Metadata
Sending an HTTP request to SharePoint
1 min· loading · loading
Will Wright
Power Automate SharePoint Flow
Update Columns in SharePoint using REST API
4 mins· loading · loading
Will Wright
Power Automate SharePoint Flow
Update Environment Variables
3 mins· loading · loading
Will Wright
Power Automate Dataverse Canvas Apps Environment Variables Flow