Adv Hands On Lab1: Package components in development environment and deploy, patch, and upgrade to production

Scenario

Application lifecycle management (ALM) is a vital part of a successful strategy for Power Platform projects. Contoso has provisioned a new development instance and would like to set up a build and deploy process where modifications of any of the components are only performed in the development environment and then deployed as a managed solution to the production environment. Components required to be deployed include a model-driven app and a canvas app. They also would like to take advantage of new tools like Solution Checker to monitor the health of what they are building.

You will be packaging components as a new unmanaged solution in the development environment and deploy, patch, and upgrade this solution in the production environment as managed.

Environment

The lab requires two PowerApps environments with a Common Data Service database created and the sample apps installed.

You are working in a shared tenant. Do not do your exercises in the default environment. You have been assigned a development environment and a production environment for this course.

Note: Specifically, for the labs in this course, it is best always to use a private/incognito browser session.

Provided for students:

Unmanaged solution that contains a model-driven app that includes account and contact.

Existing sample canvas app that uses a gallery control to display accounts.

Requirements

The following have been identified as requirements you must implement to complete the project.

R0 – In the production environment, a user must be able to start a model-driven app that includes access to Accounts and Contacts entities.

R1 – User must be able to run the canvas app providing access to accounts using a gallery control.

R2 – Maker must be able to run Solution Checker and resolve any issues flagged.

R3 – Maker must be able to add and remove components from the managed solution in the production environment by deploying patches and upgrades.

Exercise 1 – Setup the Development Environment

In this exercise, you will be preparing your new environment with some existing assets, so we can then look at how we can package all this into a solution file and deploy.

High-level tasks

Task 1– Install solution checker.

Task 2– Import solution ContosoBase. Publish it and confirm the model-driven Account Project Tracker App and its sitemap have imported.

Task 3– Import canvas app package named Accounts; open the app, and authorize its use.

Task 1: Install Solution Checker

The solution checker feature is a static analysis tool that reviews the solutions you build looking for anything that might impact performance, stability, and reliability of what you build. Currently, it requires a small installation; in the future, it will be pre-installed.

Note: As of the writing of this document, this feature is actively being added to all data centers. If you find no Solution Checker in the ribbon of your environment, don’t worry! That means you already have it and can proceed to the next task.

If you only see the install option like the image then click Install otherwise it is already installed, and you can continue to Task 2.

Click Get it Now.

Click Continue.

If you agree, accept the terms and conditions, select your dev environment and click Agree.

You should be automatically redirected to the Manage your solutions page. Locate PowerApps Checker and make sure the installation is pending. For your own enviroments you will need to use the attached applications (see below)

You may close the browser tab. The installation will continue in the background.

Click Done.

Task 2: Import Solution

In this task, you will import an unmanaged solution to your environment. This contains a small PowerApps model-driven app that we will use later.

Click Browse, select the ContosoBase solution located in the lab resources folder and click Open.

Click Next.

Click Import.

Wait for the import to complete and click Publish All.

Wait for the publishing to complete and click Close.

Click to open the imported solution Contoso Base.

You should have model-driven Customers App, a sitemap for the application, and a web resource.

Task 3: Import Canvas Application

In this task, you will import a canvas application into your environment. We are doing this using the old standalone import capability that doesn’t use solutions so we can bring in a canvas app that isn’t solution aware and then show you how to make it solution aware.

Select Apps and click Import Package.

Click Upload.

Select the Accounts app located in the lab resources folder and click Open.

Click Import.

The app package should import without errors. Click Open App.

You will be asked for permission, click Allow.

The app designer should open, and your accounts list should show data.

Close the app designer browser tab/window.

Exercise 2 – Build Solution

In this exercise, you will start building your new solution. The first step is to create a publisher and the actual solution container.

Each solution is linked to a solution publisher. The solution publisher provides information about how to contact the publisher as well as customization prefix value. When you create things like an entity that prefix is part of the name to keep it unique. For example, Contoso might use a prefix of contoso, and if they created a new entity named Project, the logical name would be contoso_project. This ensures that if another app is installed that also has an entity named Project, it won’t collide with others.

High-level tasks

Task 1: Create a solution and a publisher, both named Account Project Tracker. The publisher prefix should be set to apt. Add the following existing components:

Next, we are going to add the existing model-driven app into our empty solution. Click Add Existing | App | Model-Driven App. Add Existing is how you bring in assets that already exist and associate them with your current solution container.

Select the Customers App and click Add.

Click Add Existing again and select Other | Site Map. Model-driven apps also use a site map to define navigation, and this is a separate component. We are bringing this also into the solution, so we have all our dependencies of the app. You could also do this by selecting the model-driven app and clicking add required components.

Select Customers App sitemap and click Add.

Click Add Existing | Other | Web resource.

Select Show Name and click Add. If needed, you can search for the web resource in the search bar in the upper right-hand corner of the window.

Click Add Existing and select Entity.

Select Account and click Next.

Click Select Components. By default, when you add existing of an entity any of the fields, forms and views are not referenced. That is a good thing as it means you don’t have dependencies on those items. If you wish to change any of the existing fields, forms, or views, you can use the Select components to associate them along with the entity to your solution. Notice there is also an Include all components. This should not be used when adding existing entities that managed by other solutions like Account. It should only be used for new entities that have been created as unmanaged in this environment.

Select the Forms tab.

Select the Account form and then click Add.

Click Add again.

Task 2: Add new entity to the solution

In this task, you will add new Project entity to the solution.

Click + New and select Entity.

Enter Project for Display Name and click Create.

Make sure the Fields tab is selected and click Add Field.

Enter Start Date for Display Name, select Date Only for Data Type, make the field Required, and click Done.

Click Add Field again.

Provide the information below and click Done.

Click Add Field one more time.

Provide the information shown in the image below and click Done.

Click Save Entity in the lower right corner

Select the Relationships tab.

Click Add Relationship and select Many-to-One.

Select Account for Related Entity and click Done.

Click Save Entity.

Select Account Project Tracker and click Publish All Customizations.

Wait for the publishing to complete.

Exercise 3 – Deploy the solution

In this exercise, you will be exporting your solution from the development environment and importing it into the production environment.

You will export both an unmanaged solution and a managed solution. The unmanaged solution is for if you need to re-create your development environment in the future. The managed solution is the solution you will import into production. You should always have a matching unmanaged solution anytime you export a managed solution.

Exercise 4: Update, Patch, and Upgrade

In this exercise, you will use the patch and upgrade features of Solutions. Patches allow transporting only the changes you make. For example, if you fix the length of a field, you would add the entity and just that field to the patch solution and then that would be all you transport to production. Patches do require the initial release solution to be installed in order to install a patch.

You got the feedback below:

User doesn’t always have the Start and End Date of projects and needs to be able to create projects without these fields.

Note: In the interest of time, we have not included steps about unit testing your work and changes. In real-world implementations it’s always important to test as you go, even for the smallest of changes.

High-level tasks

Task 1: Clone a patch and remove the requirement for Start and End Date fields.

Select Solutions and click to open the Account Project Tracker solution.

Click on the … button and select Clone | Clone a Patch. When you do this, your solution is changed to read-only. A new patch solution is created. This patch solution starts out empty, and then you add into it any items you wish to change or create.

The minor version will be incremented for you, change the Display Name to Account Project Tracker Patch and click Save.

You should see a message that will tell you can’t edit the Account Project Tracker solution anymore.

Select Solutions and click to open the patch solution.

Click Add Existing and select Entity.

Select the Project entity and click Next.

Click Select Components.

Select Start Date and End Date fields and click Add.

Click Add again.

Click to open the Project entity.

Open the End Date.

Remove the requirement and click Done.

Open the Start Date.

Remove the requirement and click Done.

Click Save Entity.

Select Solutions and click Publish All Customizations.

Wait for the publishing to complete.

Select the Patch solution and click Export.

You will be prompted to publish and/or run solution checker. You can if you wish.

Click Next.

Select Managed and click Export.

Save the Patch solution on your computer.

Task 2: Import Patch Solution

In this task, you will import the Patch solution into your “Production” environment.

Your “Production” environment will now have the initial solution and the patch solutions. Click to open the Patch solution.

You should only have the components you added to Patch solution. Click to open the Project entity.

You should have only the two fields you added to the solution.

Task 3: Clone Solution

When you are ready to create the next version of your solution and are done patching the current version, you clone the solution to create the next version. This combines all patches back into the base solution file and makes the base solution file editable for you to build your next version of the solution. After being combined with the base solution, all patches are removed, and you are left with only the base solution.

You realized the Cost field in no longer needed because it is roll-up field from tasks that will be added in future date.

You also now know that you can include your canvas app in your solution and move it through your ALM process at the same time.

The two solutions will be combined, and your Dev environment will now have just one Account Project Tracker solution.

You will now delete the Cost field from Project entity. Open the Account project Tracker solution.

Click to open the Project entity.

Locate the Cost field, click on the … button and click Delete. When you delete a field of type currency, you only delete the input field. The reference to base currency will automatically also delete on save.

Click Save Entity. With this type of change a publish of customizations is not required for the changes to take effect.

We will now add our canvas app to the solution to prepare it for transport to the production environment. While still viewing your Account Project Tracker solution, click Add Existing and select App | Canvas App.

Select Outside solutions

Select the Accounts App and click Add. This will take a moment to load. You may want to refresh the hosting browser after a minute to test if is there.

The import wizard will recognize the solution as an update. Click Next.

Click Import. Notice the Stage for upgrade is checked. This is enabled any time you have patches already installed. It allows the new version to be imported and then when you click apply the old versions of the patches are removed and any destructive changes like removing fields and entities are completed and then finally the old solution is removed, and the new staged one is renamed the same as the original solution file.

Click Apply Solution Upgrade.

Click Close.

The solutions in your “Production” environment will be combined, and you will have just one solution with version 1.1.x.x. Click to open Account Project Tracker.

Excerise 1 - Task 3, shows how one can use existing canvas app and export/import works fine.

However, in ideal situation, if we start form creating a "Solution" and then create a simple entity and within the same solution (not by adding existing one). then the export from one prod. env (DEV) to another prod. env. (PROD) should enable the user's in PROD env. to be able to use Canvas App. this doesn't work as of 5-Sep-2019. Here is what i did