Package your own model using solutions

After you've registered your own model in AI Builder using a Python package, you can package your model using solutions to perform application lifecycle management (ALM) tasks, such as:

Solutions are used to transport apps and components from one environment to another. They're also used to apply a set of customizations to existing apps. For detailed information about solutions and how they're used to apply ALM concepts across Microsoft Power Platform, go to Overview of application lifecycle management.

Export your own model using a solution

In this example, you'll export two solutions:

  • The solution that contains only the custom connector
  • The solution that contains the model, connection reference, and any other components
  1. Make sure you've registered your own model in the source environment using a Python package. If you haven't already registered it, follow the procedure in Bring your own model tutorial (on GitHub).

  2. Create a solution to store the custom connector that's associated with the model:

    1. Sign in to Power Apps or Power Automate.
    2. On the left pane, select Solutions > New solution.
    3. In the New solution dialog, complete the fields. For detailed information about each field, go to Create a solution.
    4. Select Create.

    Screenshot of how to create a solution to store the custom connector.

  3. Add an existing custom connector by selecting Add existing > Automation > Custom connector.

    Screenshot of how to add an existing custom connector.

  4. Select the custom connector that's associated with the model.

    The name will be in this format: <model_name>-<random number>-v<version>. The version helps distinguish which connector to add when you update the model.

    Screenshot of the custom connector naming format.

  5. Export the solution. For help on how to export solutions, go to Export solutions for Power Apps or Export solutions for Power Automate.

  6. Create a new solution to add the model and any other components:

    1. Select Solutions > New solutions.
    2. In the New solution dialog, complete the fields.
    3. Select Create.

    Screenshot of how to create a new solution to add the model and any other components.

  7. Add an existing connection reference by selecting Add existing > More > Connection Reference (preview).

    Screenshot of how to add an existing connection reference.

  8. Add the existing connection reference associated with the model.

    The naming format is the same as the custom connector in step 4: <model_name>-<random number>-v<version>.

    Screenshot of the connection reference naming format.

  9. Add the AI model by selecting Add existing > AI Model.

    Screenshot of how to add your AI model to AI Builder.

    Your solution should contain the components shown in the following image.

    Screenshot of the three components that were added: An AI model, a connection reference, and a custom connector.

  10. (Optional) Add any components you want. In this example, we'll add a cloud flow that uses the model.

    Screenshot of new components added.

  11. Export the solution. For help on how to export solutions, go to Export solutions for Power Apps or Export solutions for Power Automate.

Import your own model into the target environment

In this example, you'll import two solutions that you created in the previous section:

  • The solution that contains only the custom connector
  • The solution that contains the model, connection reference, and any other components

For help on how to import solutions, go to Import solutions for Power Apps, or Import solutions for Power Automate.

  1. Sign in to Power Apps or Power Automate.

  2. Import the solution containing only the custom connector.

  3. Import the solution containing the model, connection reference, and any other components.

  4. During the import process, create the connection to your external endpoint:

    • If your endpoint is not secured, select Create.
    • If your endpoint is secured with an API key, enter it in the API Key field, and then select Create.

    Screenshot of the connection to an external endpoint.

Your model is now ready to be consumed in your target environment.

Screenshot of the imported solutions.

If you experience issues with your import, go to Troubleshooting solution import.

Upgrade your own model

Upgrade your solution to the latest version number so that it rolls up all previous patches in one step. Any components that were associated with the previous version of the solution and aren't in the newer version will be deleted. This ensures that outdated components won't be included in the solution.

In the examples, you'll upgrade two solutions:

  • The solution that contains only the custom connector
  • The solution that contains the model, connection reference, and any other components

For help on how to upgrade, go to Upgrade or update a solution.

Upgrade your own model in the source environment

  1. Make sure you've registered your upgraded model in the source environment by using a Python package. If you haven't already registered it, follow the procedure in Bring your own model tutorial (on GitHub).

  2. Sign in to Power Apps or Power Automate.

  3. In the solution that contains only the custom connector, add a new existing custom connector by selecting Add.

  4. Complete the fields and enter the new version. In this example, it's v2 because this is the second version.

  5. Remove the older version of the custom connector from the solution:

    1. Select the vertical ellipsis (⋮) next to the older version.
    2. Select Remove > Remove from this solution.

    Screenshot of removing an older version from a solution.

  6. Export the solution by selecting Export. By default, the version will be incremented during export.

  7. In the solution that contains the model, connection reference, and any other components, update the connection reference to point to the latest version:

    1. The custom connection will have the same name as the custom connector you added in step 4. In this example, v2 is the latest version.
    2. Remove the older version of the connection reference from the solution by selecting the name to remove (in this example v1), and then selecting Remove > Remove from this solution.
  8. Export the solution by selecting Export. The AI model and any component referencing the model are automatically updated to point to the latest version.

Upgrade your own model in the target environment

  1. Sign in to Power Apps or Power Automate.

  2. Import the solution that contains only the connector by selecting Import > Upgrade.

  3. Import the solution that contains the model, connection reference, and any other component by selecting Import > Upgrade.

  4. Create new connections to the new endpoint:

    1. If your endpoint is not secured, select Create.
    2. If your endpoint is secured with an API key, enter it in the API Key field, and then select Create.

    Screenshot of the connection to a new endpoint.

The model now will reference the new endpoint in the target environment.

Screenshot of the model referencing the new endpoint in the target environment.

Stage your own model for upgrade

Staging your model for upgrade only imports it into the organization. It doesn't make it active. In this scenario, components that reference the model in the environment will reference the old version until you complete this procedure by applying the upgrade.

For help on how to import solutions, go to Import solutions for Power Apps or Import solutions for Power Automate.

  1. Sign in to Power Apps or Power Automate.

  2. Import the solution that contains only the connector by selecting Import > Upgrade.

  3. Import the solution that contains the model, connection reference, and any other components by selecting Import > Stage for Upgrade.

  4. Create new connections to the new endpoint:

    1. If your endpoint is not secured, select Create.
    2. If your endpoint is secured with an API key, enter it in the API Key field, and then select Create.

    Screenshot of the connection to a new endpoint.

    You'll see two versions of the solution: the base and the upgrade. Any component in the environment outside of these solutions will still reference the old version of the model. Components inside of these solutions will reference the version of the model contained in the corresponding solution.

    In the following example, the cloud flow in the base solution references the old version and the cloud flow in the new solution references the new version.

    Screenshot of components before they're staged for upgrade.

  5. To upgrade the old version, select Apply upgrade.

    Screenshot of components after the upgrade is applied.

All components in the environment now reference the new version of the model.

Overview of application lifecycle management
ALM basics
Import solutions
Upgrade or update a solution