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:
- Export your own model using a solution.
- Import your own model into the target environment.
- Upgrade your own model in source or target environments.
- Stage your own model for upgrade.
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.
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
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).
Create a solution to store the custom connector that's associated with the model:
- Sign in to Power Apps or Power Automate.
- On the left pane, select Solutions > New solution.
- In the New solution dialog, complete the fields. For detailed information about each field, go to Create a solution.
- Select Create.
Add an existing custom connector by selecting Add existing > Automation > Custom connector.
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.
Export the solution. For help on how to export solutions, go to Export solutions for Power Apps or Export solutions for Power Automate.
Create a new solution to add the model and any other components:
- Select Solutions > New solutions.
- In the New solution dialog, complete the fields.
- Select Create.
Add an existing connection reference by selecting Add existing > More > Connection Reference (preview).
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>.
Add the AI model by selecting Add existing > AI Model.
Your solution should contain the components shown in the following image.
(Optional) Add any components you want. In this example, we'll add a cloud flow that uses the model.
Export the solution. For help on how to export solutions, go to Export solutions for Power Apps or Export solutions for Power Automate.
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.
Sign in to Power Apps or Power Automate.
Import the solution containing only the custom connector.
Import the solution containing the model, connection reference, and any other components.
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.
Your model is now ready to be consumed in your target environment.
If you experience issues with your import, go to Troubleshooting solution import.
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.
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).
Sign in to Power Apps or Power Automate.
In the solution that contains only the custom connector, add a new existing custom connector by selecting Add.
Complete the fields and enter the new version. In this example, it's v2 because this is the second version.
Remove the older version of the custom connector from the solution:
- Select the vertical ellipsis (⋮) next to the older version.
- Select Remove > Remove from this solution.
Export the solution by selecting Export. By default, the version will be incremented during export.
In the solution that contains the model, connection reference, and any other components, update the connection reference to point to the latest version:
- 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.
- 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.
Export the solution by selecting Export. The AI model and any component referencing the model are automatically updated to point to the latest version.
Sign in to Power Apps or Power Automate.
Import the solution that contains only the connector by selecting Import > Upgrade.
Import the solution that contains the model, connection reference, and any other component by selecting Import > Upgrade.
Create new connections to the new 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.
The model now will reference the new endpoint in the target environment.
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.
Sign in to Power Apps or Power Automate.
Import the solution that contains only the connector by selecting Import > Upgrade.
Import the solution that contains the model, connection reference, and any other components by selecting Import > Stage for Upgrade.
Create new connections to the new 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.
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.
To upgrade the old version, select Apply upgrade.
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