When working with low code and platforms such as Microsoftâs Power Platform, the idea of containerisation isnât something not considered, and is rather something very much present, similar to the pro code world!
Creating environments in the Power Platform admin center can become tedious if youâre working in a larger organisation where this is a more common exercise, or where administering environments is a regular task. In this post, weâll look at a super speedy way to create environments using the Power Platform CLI opening scope for much faster action execution!
Power Platform CLI đ¨đťâđť
So⌠weâre starting to work with CLI (command line interface) huh⌠đ§
Yes! We are â ⌠so, if you didnât check out my blog post from yesterday or you havenât worked with the Power Platform CLI before, check out how you can get it installed on your machine below using the Power Platform Tools extension in Visual Studio Code.
Authenticating with CLI đ
Before weâre able to make commands and execute operations against our tenant or environments, weâll need to work on authenticating against CLI with a persona/user that will also pass authorisation for the things we want to do.
In this post, weâre making admin commands, and creating environments so, weâll need to authenticate with a persona or âuserâ that has Power Platform Admin privileges.
To authenticate in the CLI, we will use the following command to begin with.
pac auth create
Youâll then be redirected to your default browser to login via the Microsoft login screen.
Here youâll need to sign in with the account you have which has admin privileges assigned to it.
Once youâve done that youâll see a message in the terminal confirming if authentication was successful.
From here, if things worked, we can start to make some commands to interact with our tenant and execute some operations!
Creating an environment
To create an environment we will use the following commandâŚ
pac admin create
This is the command we will use, but thereâs a number of arguments we need to provide inputs for after the command on the same line, that are equivalents as such to the inputs weâd have to populate in the admin center UI when creating an environment.
The arguments includeâŚ
Argument | Description | Alias |
---|---|---|
âname | Sets the name of the environment. | -n |
âregion | Sets the environmentâs region name. | -r |
âtype | Sets the environment Type. Values: Trial, Sandbox, Production, Developer, Teams, SubscriptionBasedTrial | -t |
âcurrency | Sets the currency used for your environment. [defaults to USD] | -c |
âlanguage | Sets the language used for your environment. [defaults to English] | -l |
âtemplates | Sets Dynamics365 app that needs to be deployed. [passed as comma separated values] e.g : -tm âD365_Sample, D365_Salesâ | -tm |
âdomain | The domain name is part of the environment URL. If domain name is already in use, a numeric value will be appended to the domain name. Eg: If âcontosoâ is already in use, then the environment URL will be updated to https://{contoso}0.crm.dynamics.com. | -d |
âinput-file | The verb arguments to be passed in a .json input file. Eg: {ânameâ : âcontosoâ}. The arguments passed through command-line will take precedence over arguments from the .json input file. | -if |
âasync | Optional boolean argument to run pac verbs asynchronously, defaults to false. | -a |
âteam-id | Team Id as Guid | -tid |
âmax-async-wait-time | Max asynchronous wait time in minutes. Default value is 60 minutes | -wt |
Arguments for pac admin create
The main ones weâre focused on for this simple command here are going to be âname, âtype, and âdomain. Iâm not worried about the others for this use case. All Iâm going to do now, is create a simple developer environment to test this out.
So Iâm now going to input this command to the terminal and hit enter.
pac admin create --name "Power Platform Dev" --type Developer --domain powerplatformdev
Things should take a little while to finish up, and if things were successful youâll see a message suggesting things completed with a status code of OK, followed by details of the environment you just created.
Finally, we can also double check that the environment can be seen from the Power Platform Admin Center (admin.powerplatform.microsoft.com)
And there we go! I can also now see my environment in the admin center.
Upcoming content
This is just the first of many more posts going through the Power Platform developer tools covering a number of topics within tools such as the Power Platform CLI, through to the Dataverse development tools such as the configuration migration tool, and ALM tools such as the Power Platform Build Tools for DevOps or GitHub actions! đ
Thatâs right! This is going to be a pretty chunky series, so make sure youâre subscribed to get all of my upcoming content on the Power Platform developer tools and more! đŠ
Subscribe