How to Automate Copilot Studio Agent Deployment to SharePoint
Recently, I’ve been working with the Power Platform team on an AI Accelerator program. The program focuses on onboarding business users to build their own agents for business use cases in Copilot Studio.
While onboarding makers, we ran into a few challenges with publishing agents to the SharePoint channel:
- Access restrictions in QA: Makers don’t have the access needed to publish agents themselves, so they depend on the admin team.
- Admin access requirements: To deploy an agent from the Copilot Studio maker portal UI, the admin needs owner or member access on the agent.
- Manual bottleneck: This back-and-forth between makers and admins adds friction and slows down deployments.
To solve this, we automated the deployment of Copilot Studio agents to the SharePoint channel using a simple cloud flow. In this blog, we’ll walk through how to set it up.
Prerequisites
- A published agent in the target environment (or one already moved from Dev to QA)
- A SharePoint site where the agent will be deployed
- Permission to upload files to that SharePoint site
- A Power Automate (cloud flow) license or access to create flows in the environment
Scenario
An agent called “Weather Assistant” is already published in the environment:

Using power automate cloud flow, we will deploy this agent to a SharePoint site:

Solution
Step 1: Create a new Solution
It’s always recommended to start with a new solution, so create one with a valid publisher of your choice. Here, I’ve created a solution called “CSA SharePoint Deployment”:

NOTE: Pls ignore the solution components in the above screenshot, you will find it empty when you create a new Solution
Step 2: Add an environment variable
In the solution, add an environment variable to store the JSON structure for the deployment file, with placeholders for the values we’ll fill in later. Here, I’ve added a variable called “Agent_SharePointDeployment_JSON”:

Enter the below code in the current value of the environment variable:
{
"schemaVersion": "0.2.0",
"copilotStudioMetadata": {
"state": "Published",
"botMetadata": {
"botSchema": "_agentSchema",
"environmentID": "_enviornmentId",
"hostnameSuffix": "api.powerplatform.com",
"transport": "rest"
},
"name": "_agentName",
"deepLinkUrl": "https://copilotstudio.microsoft.com/environments/_enviornmentId/copilots/_agentId/details",
"icon": "data:image/png;base64,_iconBase64Value"
}
}
Save the environment variable.
Step 3: Design the manual trigger cloud flow in the Solution
In the solution you created above, create a cloud flow with a manual trigger and name it “Deploy Copilot Studio Agent on SharePoint Channel.”
Add two input parameters to the trigger:
| Name | Data type |
|---|---|
| AgentName | String (Single line of text) |
| SharePointSiteURL | String (Single line of text) |

Next, add a Compose action with an expression that reads the environment ID at run time.
workflow()

Now, add a List rows action to query the “Agent” Dataverse table by the agent’s name. We’ll use the output of this action to get the agent metadata. Set the Filter rows field to:
name eq '@{triggerBody()?['text']}'

Next, add a Condition action to check whether the query actually returned an agent. We’ll test the length of the array returned by List rows. Use this expression on the left side of the condition:
@{length(outputs('List_rows_-_Agent')?['body/value'])}
Set the condition to check whether this value is greater than 0.

If the condition is false (no matching agent was found), add a Terminate action in the false branch to stop the flow. Optionally, you can also send an email or Teams notification in that branch to let the user know the agent wasn’t found in the Dataverse table.

If the condition is true (an agent was found), add a Compose action in the True branch to replace the placeholders in the environment variable with the agent metadata returned by List rows. Because the List rows output is an array, we use the first() function to read values like name, agent ID, schema name, and so on. Use the following expression:
json(replace(replace(replace(replace(replace(string(parameters('Agent_SharePointDeployment_JSON (smd_Agent_SharePointDeployment_JSON)')),'_agentSchema',first(outputs('List_rows_-_Agent')?['body/value'])?['schemaname']),'_enviornmentId',outputs('Compose_-_Workflow')?['tags']?['environmentName']),'_agentId',first(outputs('List_rows_-_Agent')?['body/value'])?['botid']),'_iconBase64Value',first(outputs('List_rows_-_Agent')?['body/value'])?['iconbase64']),'_agentName',first(outputs('List_rows_-_Agent')?['body/value'])?['name']))

Next, add another Compose action to store the SharePoint folder path where the file will be uploaded:
/Shared Documents/Copilot Studio Agents

Finally, add the SharePoint Create file action to upload the .agent JSON file to the document library. Configure it as follows:
Site Address: pass the SharePointSiteURL value from the trigger’s input parameter.:

Folder Path: pass the output of the Compose action that stores the folder path

File Name: use the expression below:
@{first(outputs('List_rows_-_Agent')?['body/value'])?['name']}_@{first(outputs('List_rows_-_Agent')?['body/value'])?['schemaname']}.agent
File Content: pass the output of the Compose action that holds the final deployment JSON:

Save & publish the flow.

Optionally, you can add action to send notification to the user for successfully deploying agent in SharePoint site.
Run flow
Run the flow with valid Agent Name & SharePoint URL:

The flow runs successfully:

Output
Let’s verify the result. Go to your SharePoint site and navigate to Documents → Copilot Studio Agents. You’ll see the .agent file stored there.

Click the .agent file name to open the agent in the side panel:

Interact with the agent to confirm it responds and works as expected:

Conclusion
By automating the deployment of Copilot Studio agents to the SharePoint channel, we’ve removed a recurring manual task from the admin team’s plate. Instead of publishing each agent through the maker portal UI, the admin (or the maker) simply runs a single cloud flow with the agent’s name and SharePoint URL.
This brings several benefits for the admin team:
- No more repetitive manual deployments: Admins no longer have to publish each agent individually through the Copilot Studio maker portal, freeing up their time for higher-value work.
- No elevated access required per agent: Admins no longer need to be added as owner or member on every individual agent just to deploy it.
- Fewer maker-admin back-and-forths: Makers are no longer blocked waiting on the admin team which removes the bottleneck and reduces the support requests admins have to field.
- Consistent, error-free deployments: The flow uses a standardized JSON template, so every agent is deployed the same way – no manual steps to get wrong.
- Scalable onboarding: As more makers join the AI Accelerator program, the admin team can support the growth without deployment work increasing at the same pace.