Sunday, September 24, 2023

Publish your App on AppSource- Dynamics 365 | Power App

How to publish power apps on Microsoft Appsource from scratch?

Scenario: I have a Canvas app in a separate unmanaged solution. To prepare it for AppSource, I'll first download it as a managed solution and generate an AppSource package using Visual Studio. This process involves creating input.xml, content types XML files, and terms of use HTML files. Finally, we will zip all the files, including the app logo, and upload them to blob storage to get the URL which I'll then submit to the Microsoft website for app validation and publication. The entire process includes 5 stages of confirmation, and once it passes all of them, the app will be successfully published and available to clients/users on MS App source.
Once your package successfully clears all validations, it will be prepared to go live, and you should expect to see the following status in your Microsoft partner account.


Follow the video to see its implementation Part 1 and Part 2
  

Note- The steps mentioned in the Microsoft blog need to be revised. I followed the steps mentioned in the MS blog and submitted it for publishing, but it failed in the validation stage. I also made several other errors, which I will show you in this blog.

There are five validation stages for publishing an app. Our package has successfully passed the critical automated validation phase, and it received confirmation that it meets expectations.


However, even if you've followed all the steps correctly, the Microsoft team may reject your app publication if it uses deprecated APIs or codes that are not recommended. In our case, Microsoft advised us that we used certain components like DOM and parent relationships, which are discouraged during the app development. They recommended replacing these with the supported Client API object model.


Microsoft Support Form
This is a Microsoft support form where they may request details and provide assistance. You can access it here: Support Form
Errors - I've shared various errors below that I encountered from Microsoft teams during the package-sharing process for publication and the package creation and deployment.
Prerequisite - 

  • Visual Studio 2019
  • Power Platform tools in Visual Studio or 
  • Microsoft Power Platform CLI
  • Managed solution of your app

There are total 5 steps involved in this (explained in detail below)


Step 1: Create a Microsoft Partner Center account 

Step 2: Create a managed solution for your app 

Step 3: Create an AppSource package for your app 

  • Create connection
  • Create deployment package
  • Create input and ContentTypes files in XML
  • Add app logo (32x32 size in PNG/JPG format)
  • Zip all the above fields to create a Final package

Step 4: Store your package on Azure Storage

Upload the package in Azure blob and get the URL


Step 5: Submit your app on Partner Center

Share the detail and blob URL for validation and wait for it.


Let's see how to create a package structure with the step-by-step process. First, we'll create a Microsoft Partner Center account and download the managed solution through PowerApps. The third is creating an AppSource package in Visual Studio for the app. After this, we will make input type.xml and content types.xml and zip all files into a package. The fourth one is Azure Storage, which generates a URL with the SAS key. Lastly, we will upload the URL to the MS partner account for validation and publication of the app.

Step 1: Create a Microsoft Partner Center account

Firstly, we need to have a Microsoft Partner Center account. If you need to become a member of the Microsoft Partner Center, you must enroll at https://aka.ms/joinmarketplace. You must be a member of the Partner Center to publish apps on AppSource. 
Note - If you're using your company's email in your Microsoft Partner Center account, you must request MPN admin access to view settings and publish the app.
Below are general steps for creating an account, click on the Microsoft Partner Center account and provide the requested details in each Step. If you already have a Microsoft Partner Center account, skip the steps below and go straight to Step 2.

You'll receive the following message if you already have an account with the same email address.

You must request MPN admin access to view settings and publish the app.

Step 2: Create a managed solution for your app

First, let's see how to create a solution. Login to powerapps.com with your user ID and password.
Click on your solution and select "Export."

Ensure all customizations are published. Click on the Publish button for this.
Click "Next."

Choose "Managed" as recommended, and proceed to export.
Once the export is complete, download it and locate it in your downloads folder. Copy the file path and paste it into a notepad for future reference to execute in its CLI
My solution path-  "C:\Users\RajnishMahaseth\Downloads\AugustSolution_1_0_0_1_managed.zip" 
Now, we are moving to the third Step.  

Step 3: Create an AppSource package for your app

Create an AppSource package (.zip file) to include your solution and other required files. An AppSource package consists of the following files:

This Step focuses on creating a package project and outlines how to use the CLI and PowerPlatform. There are two methods for creating a package structure: one using Visual Studio Code and the other using Visual Studio 2019.
Visual Studio download link - here
Visual studio code  download link- here
In both cases, we'll be using the same commands. For simplicity, I'll choose Visual Studio 2019. First, let's explore Microsoft PowerPlatform CLI. There are two ways to use it: through Visual Studio Code and through PowerPlatform CLI for Windows using Command Prompt or PowerShell. Visual Studio Code is suitable for Mac OS, Windows 10, and Windows 11, while the second method is exclusive to Windows. If you're on a Mac, go with Visual Studio Code; if you're on Windows, you can choose either way. Now, let's dive into how to create a package using Visual Studio on a Windows machine.

We will require the environment URL where the solution is located.
Log in to Dynamics CRM →Click on "Settings."→ Navigate to the "Admin Center."

Go to environments from the left pane and open your environment.


Copy the Environment URL (e.g., https://org44ad4e8e.crm.dynamics.com/). You will need this when establishing a connection from either Visual Studio or the CLI.

Open Visual Studio, and click on continue without code.

We need to have Power Platform Tools to make the package and run commands for it. So go to Extension→Manage Extension→Find Power Platform tool and install it.


After the installation, the PowerShell terminal will be opened. We can start executing the commands for creating the package. (Since it is already installed,  it is not showing the install option. You can install it. Once it is installed,  click on the terminal. A new window will be opening. Just execute the below commands)

Create a new folder on your desktop (or any preferred location). This folder will be the storage location for all the necessary items to create the package.
My folder location is C:\Users\RajnishMahaseth\Desktop\DynamixPower
Let's open that path first in the terminal

Execute Command 1 - cd C:\Users\RajnishMahaseth\Desktop\DynamixPower


Now, let's establish a connection with Dynamics 365. We'll require the environment URL path we copied in the previous Step (e.g., https://org44ad4e8e.crm.dynamics.com/).
Command 2 - pac auth create --name RajnishMahaseth --URL https://org44ad4e8e.crm.dynamics.com/
You'll be prompted to log in. You can select the logged-in account if the Dynamics 365 environment belongs to the same account or choose "Use another Account."


Once the connection is established, you will see the message "Authenticated successfully."

Command 3 - pac package init --outputDirectory DeploymentPackage This will generate a folder named "DeploymentPackage" containing the deployment package. After executing this command, you'll receive the message "Package project created successfully."


 Next, we'll navigate inside this package. 
Command 4 - cd .\DeploymentPackage\


We are including the solution in this package. Here, you need to specify the path where the managed solution was downloaded in Step 2.
Command 4 - pac package add-solution --path "C:\Users\RajnishMahaseth\Downloads\AugustSolution_1_0_0_1_managed.zip"



The fifth command is "dotnet publish," which we will use to publish the package.
Note: if these four commands don't work after installing the .msi, please try to install the latest version of the .net.  After installing this latest version of the .net, you can execute all these four commands. One more thing is that if you have multiple solutions in your request, you can run the third command. How many solutions you have you can execute that many times.

Command 5 - dotnet publish



Open the folder where you're executing these commands, you should see a folder structure like this:
The deployment package is created successfully. Your package is comprised of the following files within the `<Project>\Bin\Debug` folder:
<PackageName> folder: The folder is named according to your package folder name, as changed in step 2.g of this section. You'll find all solutions, configuration data, flat files, and package contents in this folder.
You may also encounter a `.NET` folder (e.g., net472) containing a `pdpublish` folder. Your DLL and other project files are in this `pdpublish` folder.
<PackageName>.dll: This assembly holds the custom code for your package, and by default, it shares the same name as your project.

Optional Step (you can skip it; the package is already built, so it won't impact anything). This Step is for testing the app in another environment. After you create a package, you can deploy it on the Dataverse instance.
To deploy using the CLI, use the pac package deploy command.
Command 6 -pac package deploy --package .\bin\Debug\DeploymentPackage.1.0.0.pdpkg.zip
You may encounter an error here: "An error occurred for solution DynamixPower. You cannot replace an unmanaged version of this solution with a managed one."
Solution: It's not possible to have both a managed and an unmanaged solution with the same name and version in the same environment. To resolve this, attempt to deploy it in a different environment. Rerun command 2 with a different environment URL.

Be aware that you might encounter dependency issues in the new environment. Managed solutions often rely on other solutions or components within the target environment.

In summary, we've created a folder named "DeploymentPackage," added the solution to this package, and then published the package.
Let's open the folder and go to bin→debug and copy the "DeploymentPackage.1.0.0.pdpkg" zip file.


Now, let's create a folder. I am giving it a name as a Package. Paste that dpkg file over here.
Create an icon for your app source package. The size should be 32x32. Or download your company logo(size 32x32  and move it to this package location. Name it logo32x32. Valid file formats are PNG and JPG. Now let's create input and content types XML files

Creating [Content_Types].xml Open the folder(Package) we previously created. (Make content types and input files should be of only XML format and not be any other documents.) Right-click on mouse→New→Text Document. Now open that document in Notepad.


Go to this Microsoft page for copying code of [Content_Types].xml. Create an AppSource package for your app. Click on copy and paste code in Notepad.

[Content_Types].xml file that provides MIME type information of the file type extensions included in your package. This is separate from the one that will be included again in the AppSource package. The naming convention should be the same as in the document. We need to save it in XML format. Click on File→Save as

Give file name as [Content_Types].xml and save it
Note - If you have other extensions here, such as  CSV,  you can copy this command and paste it down. For example, here, msapp is there. You can add CSV. Once it is done,  click on save and close it. e.g. <Default Extension="csv" ContentType="application/octet-stream" />

Creating input.xml 
Go to this Microsoft page. Create an AppSource package for your app, and copy the input.xml. Navigate to the folder. The same document has been opened previously. Just open it. Paste it.


We need to make specific adjustments to the information in the input file to align it with our package details. Let's begin by editing the input.xml file.

  • Here, you will find the provider's name, which can be your company's name or any other designation you prefer.
     <ProviderName>PowerDynamix</ProviderName>
  • Next, focus on the package file, which originates from the CLI command. Simply copy this dpkg file and rename it if desired. When you rename it, paste the new name, along with the extension, into a notepad. Remember that extensions are mandatory.
     <PackageFile>DeploymentPackage.1.0.0.pdpkg.zip</PackageFile>
  • Now, let's address the solution anchor name. This name should differ from your managed solution's name. Since it's already in the notepad, copy and paste it along with the extension.
    <SolutionAnchorName>AugustSolution_1_0_0_1_managed.zip</SolutionAnchorName>
  • The start date should be formatted as MMDDYY and set to two days before the current date. Additionally, the end date can be any date, but it must be at least one month from today's date, and it should also follow the MMDDYY format. 
     <StartDate>20/09/2023</StartDate>
    <EndDate>01/01/2031</EndDate>
  • Moving on to supported countries, consult the document for the list of countries. Decide which regions you want to publish your app, then copy and paste these regions into the notepad. You can edit them as needed, but ensure no spaces or new lines between the country codes. For clarity, separate the country codes with commas and ensure that supported countries remain on the same line, including the ending tag.
    <SupportedCountries>US, CA,AD,AE,AF,AG</SupportedCountries>
  • Regarding the "Learn More" link, you can use your company's website link. 
    <LearnMoreLink>https://powerdynamixx.blogspot.com/</LearnMoreLink>
  • As for the package's local code, the default is 1033 for English. If you plan to publish your app in different regions, refer to the document for the appropriate local codes.
  • Additionally, ensure that the package's local code matches the solution.xml file. Open the solution.xml file located within the pdpkg folder. If multiple languages exist in the solution.xml file, ensure that the input.xml file contains the corresponding language codes. Both the solution.xml file's local codes and language codes should match those in the input.xml file.
  • Regarding the logo, follow the naming convention mentioned in the folder. If the logo is 32x32, use the same naming convention and extension in the input.xml file. 
    <Logo>logo32x32.png</Logo>
  • The same naming convention and extension should also be applied to the terms of use in the user.html file. (I will show how to create an HTML file in the next Step.)
    <PackageTerm File="TermsOfUse.html" />
In summary, ensure all aspects of the input.xml file adhere to these guidelines. Avoid errors when publishing the offer by ensuring correct extensions, the right package file name, distinct solution anchor names, and properly formatted start and end dates. Maintain a consistent format for supported countries, match language codes, and follow the naming conventions for logos and terms of use.
If you have any data files, incorporate them into the input config files by referencing the document and adding the necessary attributes.
Once details are modified, click save as and save the file name as Input.xml and save it.

Now, let's delete this text document from the package folder. The next is to create an HTML file for the license. It should be in .html. Your terms and conditions can be created by the HTML file.

Creating TermsOfUse.html Create an HTML file containing your license terms. If your app supports multiple languages, you can have an HTML file per language to display the license terms in the user-selected language. The HTML file is mandatory. Open Notepad or Notepad++. Create an HTML file containing your company's terms and conditions, then save it in HTML format.


The package is now fully prepared. Refer to the snapshot below; your Package folder should contain the following files.
Select all the files, then compress them directly. This will create the final package. Be sure to cut and paste it outside the folder for clarity. Once the final package is ready, let's proceed to copy just the fourth URL.

Step 4: Store your AppSource Package on Azure Storage & generate a URL with the SAS key

To maintain the security of your files, we need to store the AppSource package file in a Microsoft Azure Blob storage account and use a Shared Access Signature (SAS) key to share the package file. Your package file is retrieved from your Azure Storage location for certification and then for AppSource trials.
If you're using a company account, ensure you have access to the blob storage. If you don't have access, request it.

Here are the steps in the process:

  • Begin by logging into azure.microsoft.com and signing in to portal.azure.com.
  • Once signed in, navigate to the storage section and create a container from there.
  • For more comprehensive instructions on creating containers, refer to the provided documentation below.
  • Set the start date two days before, as specified in the input.xml, and ensure that the expiry time is set to at least one month.
  • After you've completed these steps, proceed to generate the SAS URL.
  • Copy the generated SAS URL and paste it into the partner center to upload the package.

Here are the steps from the Microsoft page: Store a package in Azure Storage

To upload your package to Azure Blob storage:

  1. Create a free trial or pay-as-you-go Azure account at https://azure.microsoft.com.

  2. Sign in to the Azure Management portal at https://portal.azure.com.

  3. Create a new Storage account by clicking > Storage > Storage account - blob, file, table, queue.

    Create a Storage account

  4. On the Create storage account page, specify the NameResource group, and Location for your storage account. Leave the rest of the columns with the default options. Click Create.

    Specifying account values

  5. After your storage account is created, navigate to the newly created resource group, and create a new Blob container. Under Blob Service, select Containers, and then + Container.

    Create a new Blob container.

  6. Specify a name for your container, and select the Public access level as Blob. Click OK.

    Set access level of the Blob.

  7. Start Azure Storage Explorer on your computer, and connect to your Azure Storage account by signing in using the same account with which you created your Azure Storage account.

  8. In Azure Storage Explorer, select the newly created container, and then select Upload > Upload Files to upload the app source package that you created in Step 4: Create an AppSource package for your app.

    Upload the app source package.

  9. Browse to the AppSource package file on your computer, and select to upload it.

  10. Right-click on the uploaded AppSource package file, and select Get Shared Access Signature.

    Selecting Shared Access Signature

  11. On the Shared Access Signature page, modify the Expiry time value to make the Shared Access Signature (SAS) active for a month from the Start time. Click Create.

    Set an expiration time

  12. The next page displays information about the generated SAS information. Copy the URL value and save it for later. You will need to specify this URL while creating an offer in the Partner Center.

    Copying the SAS URL


Submit your app on Partner Center

Once you have obtained the URL from blob storage, you can use the Partner Center (link here)to submit your app for listing on Microsoft AppSource. As previously mentioned in step 1, ensure you have MPN admin access to manage settings and publish the app.
Snap of a user having access

Snap of a user having no access

Once your package successfully clears all validations, it will be prepared to go live, and you should expect to see the following status in your Microsoft partner account.

Errors during the package sharing process for publication and the package creation.


Error 1- We found the below error in your package- unable to download the file from the Azure blob that you have provided at the partner's center.  URL of the package location is either no longer available or it is missing authentication tokens.

Solution- To resolve this issue, you should renew your blob URL and then update the new URL within the Partner Center. After making this adjustment, you can proceed to publish your package once again. When generating the SAS token, ensure you set the start date to the current date minus one day and the end date to the current date plus ten days. For more information and guidance, you can refer to the reference
link here

Error 2- This XML file does not appear to have any style information associated with it. The document is shown below. Authentication failed. The server fails to authenticate the request.

Solution- check how you are constructing the authorization header in your application. Ensure that it includes all the required components, such as the Shared Key Signature, and that it is correctly formatted.

Error 3 - Folder structure issue: The folder structure that you mentioned inside the BLOB package was incorrect. Please refer to the below guideline URL for proper package structure.

Solution- Ensure that all the necessary files and components of your app are in the correct locations within the package. This includes any metadata files, icons, images, configuration files, and the main application files.

Error 4 - Syntax Error in Input.xml file - two times zip.zip

Solution- Ensure that you include the extensions of all files in the input.xml file. Avoid duplication or omission when copying and pasting.

Error 5 - Syntax Error in Input.xml file - missing header for <LearnMoreLink>
Solution- Ensure to place the end header of all files in the input.xml file.

The next error you may encounter occurs only after successfully passing all automation validation stages. This error arises during manual validation checks and may be attributed to the use of certain components, such as DOM elements and parent relationships, which were employed during the app's development but are not recommended.

Error 6 - Code Issues in Canvas App:
Check for usage of DOM in the form
Check if the parent relationship is used

Solution- We need to review and update the code of our Canvas app and re-submit your package
Here are some recommended references by Microsoft to follow (with link):

4 comments:

  1. when client downloads the app source app(powerapps solution( is source code visible to them?

    ReplyDelete
    Replies
    1. When you publish any power app after packing it as managed solution then the source code will be hidden from users and cannot be edited.

      Delete
  2. It is great article. I am having PowerApp with SharePoint as backend, is it possible to deploy this kind of app?

    ReplyDelete
    Replies
    1. Thanks for your kind words.
      Yes, it is absolutely possible to deploy a PowerApp that uses SharePoint as a backend.

      Delete

Followers

Power Dynamix YouTube Videos