The error message "App id {PowerAppAppID} needs to be installed to the scope {MyAppId}:{ChannelId} and be in an unblocked state to install/update a tab" indicates that the Power Apps app must be pre-installed in the team before you can add it as a tab.
Since you’re provisioning new teams programmatically, you need to install the Power Apps app first before adding the tab. Here's how you can do it:
Solution: Install the Power Apps App to the Team First
Before adding the tab, you must install the Power Apps application in the team. You can do this via Microsoft Graph API using the following steps:
Step 1: Install the Power Apps App in the Team
Use the Graph API to install the Power Apps app in the team before attempting to add the tab.
POST Request
Payload
- Replace
{PowerAppsAppId} with the Teams App ID for Power Apps.
- This step ensures the Power Apps app is installed in the team.
Step 2: Wait for Installation to Complete
After installing the app, you must wait a few seconds before adding the tab. You can do this by:
- Adding a Delay action in Power Automate (5-10 seconds).
- Polling the team’s installed apps to confirm installation.
To verify installation, use:
Check if Power Apps appears in the response.
Step 3: Add the Power Apps Tab
Once the Power Apps app is installed, you can use your existing POST request to add the tab.
Make sure the payload contains:
- The correct Power App ID (
MyAppId).
- The correct team and channel IDs.
Final Approach in Power Automate
-
Create a Power Automate flow that:
- Provisions the team.
- Installs the Power Apps app (Step 1).
- Waits for installation (Step 2).
- Adds the Power Apps tab (Step 3).
-
Use a Custom Connector for the Graph API requests.
Alternative: Use Teams Templates
If you're provisioning similar teams frequently, consider Teams Templates:
- You can create a template that includes the Power Apps app by default.
- This removes the need for installing it dynamically.
Conclusion
You need to install the Power Apps app first before adding it as a tab. This can be done via:
- Graph API request to install the app.
- Delay or check if the app is installed.
- Then add the tab using your existing request.
This should fully automate the process and remove the manual steps.