Поделиться через


Build an Agent 365 agent deployed in Google Cloud Platform (GCP)

Important

You need to be part of the Frontier preview program to get early access to Microsoft Agent 365. Frontier connects you directly with Microsoft’s latest AI innovations. Frontier previews are subject to the existing preview terms of your customer agreements. As these features are still in development, their availability and capabilities may change over time.

Learn how to build, host, register, and publish an Agent 365 agent running on Google Cloud Run, using the Agent 365 CLI. Microsoft Entra & Graph provides the agent identity, permissions, and blueprint, while Google Cloud Run provides the runtime.

If all you want to do is point your agent to your code residing behind an AWS endpoint, you only need this additional step: Configure for non-azure hosting and then follow all other steps from Agent 365 Development Lifecycle.

Goals

Learn how to use Agent 365 and Microsoft 365 as the 'control plane' and:

  • Deploy agent runtime on Google Cloud Run
  • Configure a365.config.json for non‑Azure hosting
  • Create Agent Blueprint in Entra ID
  • Configure OAuth2 + inheritable permissions
  • Register Bot Framework messaging endpoint pointing to GCP
  • Create Agent Identity + Agent User
  • Publish to Microsoft 365 app surfaces
  • Test interactions end-to-end

Prerequisites

Before you begin, ensure the following Azure / Microsoft 365, Google Cloud Platform (GCP), and local environment prerequisites are met.

Azure / Microsoft 365 prerequisites

Confirm your Microsoft Entra tenant access and install the following tools to create identities, blueprints, and register your agent.

GCP prerequisites

  • GCP project created

  • Cloud Run API enabled

  • gcloud SDK installed and authenticated:

    gcloud auth login
    gcloud config set project <GCP_PROJECT_ID>
    gcloud config set run/region us-central1   # or your preferred region
    

Local development environment prerequisites

  • Code Editor: Any code editor of your choice. Visual Studio Code is recommended

  • (Optional) Node.js. You can use any language for your agent. This article uses Node 18+ in the following steps.

  • LLM API access: Choose the appropriate service based on your agent's configuration or your preferred model provider:

Create & Deploy Agent 365 Agent to Cloud Run

This example uses a minimal example agent that:

  • Responds to GET /
  • Accepts Bot Framework activities on POST /api/messages

Create project

Follow these steps to scaffold a minimal Node.js agent that runs on Cloud Run and accepts Bot Framework activities.

  1. Create the project directory

    mkdir gcp-a365-agent
    cd gcp-a365-agent
    
  2. Initialize the Node project

    npm init -y
    npm install express body-parser
    
  3. Create index.js

    const express = require("express");
    const bodyParser = require("body-parser");
    
    const app = express();
    app.use(bodyParser.json());
    
    app.get("/", (req, res) => {
    res.status(200).send("GCP Agent is running.");
    });
    
    // Bot Framework Activity Handler
    app.post("/api/messages", (req, res) => {
    console.log("Received activity:", JSON.stringify(req.body, null, 2));
    
    // Echo activity
    const reply = {
       type: "message",
       text: `You said: ${req.body?.text}`
    };
    
    res.status(200).send(reply);
    });
    
    const port = process.env.PORT || 8080;
    app.listen(port, () => console.log("Server listening on port " + port));
    

Deploy to Google Cloud Run

Use gcloud run deploy to build and run the service on Cloud Run, then note the public URL for your messagingEndpoint.

  1. Use the following commands to deploy your project to Google Cloud Run:

    gcloud run deploy gcp-a365-agent `
    --source . `
    --region us-central1 `
    --platform managed `
    --allow-unauthenticated
    
  2. When finished, note your endpoint:

    https://gcp-a365-agent-XXXX-uc.run.app
    

    This URL is the messagingEndpoint used by the Agent 365 Dev Tools CLI in the next step.

Configure for Non-Azure Hosting

Create a365.config.json in your Cloud Run project folder by running a365 config init:

{
  "tenantId": "YOUR_TENANT_ID",
  "subscriptionId": "YOUR_AZURE_SUBSCRIPTION_ID",
  "resourceGroup": "a365-gcp-demo",
  "location": "westus",
  "environment": "prod",

  "messagingEndpoint": "https://gcp-a365-agent-XXXX-uc.run.app/api/messages",
  "needDeployment": false,

  "agentIdentityDisplayName": "MyGcpAgent Identity",
  "agentBlueprintDisplayName": "MyGcpAgent Blueprint",
  "agentUserDisplayName": "MyGcpAgent User",
  "agentUserPrincipalName": "mygcpagent@testTenant.onmicrosoft.com",
  "agentUserUsageLocation": "US",
  "managerEmail": "myManager@testTenant.onmicrosoft.com",

  "deploymentProjectPath": ".",
  "agentDescription": "GCP-hosted Agent 365 Agent"
}

The following table summarizes important configuration fields and their purpose.

Field Meaning
messagingEndpoint Your Cloud Run URL + /api/messages
"needDeployment"=false Tells CLI 'I host my own server; don't deploy to Azure'
deploymentProjectPath Where .env stamping happens

Build Agent 365 agent

Once you have your agent code running against an AWS endpoint, follow remaining steps from Agent 365 Development Lifecycle to setup your Agent 365 agent.

Verify the agent end-to-end

Use these checks to confirm your GCP-hosted agent is reachable, receiving Bot Framework activities, and responding correctly across Agent 365 surfaces.

Verify Cloud Run connectivity

Send a GET request to the messagingEndpoint value from your a365.config.json:

curl https://gcp-a365-agent-XXXX.run.app/

The response body should include:

GCP Agent is running.

Check Cloud Run logs for incoming Bot Framework messages

You can check Google Cloud Log Explorer or run:

gcloud run services logs read gcp-a365-agent --region <your region> --limit 50

After a message hits your agent, you should see:

POST 200 /api/messages
Received activity: { ... }

Test agent from Agent 365 surfaces

Depending on your environment:

  • Agents Playground
  • Teams (if published)
  • Agent Shell

You can now send messages and verify your Cloud Run logs. And you can also Learn how to test agents using the Microsoft Agent 365 SDK and validating your agent's functionality with the Agents Playground testing tool.

Developer Workflow

Once setup is complete, follow this workflow for iterative development:

  1. Change your agent code

    Make your code changes, save, and test locally before deploying.

  2. Redeploy to Google Cloud Run

    gcloud run deploy gcp-a365-agent --source .
    
  3. Test and monitor

    Test via Agent 365 surfaces and monitor Google Cloud Run logs.

    Note

    Your identity, blueprint, bot endpoint, and permissions DO NOT need to be recreated.

Troubleshooting

Use this section to diagnose common issues when deploying and running your Agent 365 agent on Google Cloud Run, and to quickly apply fixes for connectivity, configuration, and licensing problems.

Messaging endpoint isn't hit

Check the following details:

  • The endpoint is exactly:
    https://<cloud-run-url>/api/messages
  • Cloud Run allows unauthenticated access
  • No firewall rules

License assignment fails

Assign a valid Microsoft 365 frontier license manually, or use an unlicensed user path if supported.

Getting help

More help options

Consider the following to find help: