This guide shows the exact az rest calls to create, list, and delete an AI Foundry SharePoint grounding connection.
You’ll touch two different API surfaces:
- Control plane (ARM):
https://management.azure.com- Use this to create / update / delete the connection resource.
- Project data plane (Foundry project endpoint):
https://<accountName>.services.ai.azure.com/api/projects/<projectName>- Use this to list/get connections and to call get-with-credentials.
The project data-plane endpoints used in this guide are:
GET {projectEndpoint}/connections?api-version=v1GET {projectEndpoint}/connections/{connectionName}?api-version=v1POST {projectEndpoint}/connections/{connectionName}/getConnectionWithCredentials?api-version=v1
- Azure CLI:
az --version - Signed in:
az login - You have permission to manage the AI services account / project.
Replace the placeholders below:
# Azure subscription + Foundry project identity
$subscriptionId = '00000000-0000-0000-0000-000000000000'
$resourceGroup = 'rg-example'
$accountName = 'my-ai-services-account' # Microsoft.CognitiveServices account name
$projectName = 'my-foundry-project'
# Connection name you will create in the project
$connectionName = 'sharepoint_grounding_demo_001'
# SharePoint site OR folder URL (single value per connection)
$sharePointSiteUrl = 'https://contoso.sharepoint.com/sites/Policies'
# API versions used by these calls
$armApiVersion = '2025-04-01-preview'
$armBatchApiVersion = '2015-11-01'
$foundryApiVersion = 'v1'$url = "https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.CognitiveServices/accounts/${accountName}/projects/${projectName}/connections/${connectionName}?api-version=${armApiVersion}"The payload supports one SharePoint URL per connection (a site or a folder).
$payload = @{
properties = @{
authType = 'CustomKeys'
category = 'CustomKeys'
target = '_'
isSharedToAll = $false
credentials = @{ keys = @{ siteUrl = $sharePointSiteUrl } }
metadata = @{ type = 'sharepoint_grounding' }
}
}
$tmp = New-TemporaryFile
($payload | ConvertTo-Json -Depth 20) | Set-Content -LiteralPath $tmp -Encoding utf8NoBOM
az rest --method put --url $url --body "@$($tmp.FullName)" --headers 'Content-Type=application/json' --output jsoncVerify with ARM GET:
az rest --method get --url $url --output jsoncBatch endpoint:
POST https://management.azure.com/batch?api-version=2015-11-01
Notes:
- Use
requests[i].httpMethod,requests[i].relativeUrl, andrequests[i].content. - Do not include per-request
headersinsiderequests[i].
$rel = "/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.CognitiveServices/accounts/${accountName}/projects/${projectName}/connections/${connectionName}?api-version=${armApiVersion}"
$batch = @{
requests = @(
@{
httpMethod = 'PUT'
relativeUrl = $rel
content = @{
properties = @{
authType = 'CustomKeys'
category = 'CustomKeys'
target = '_'
isSharedToAll = $false
credentials = @{ keys = @{ siteUrl = $sharePointSiteUrl } }
metadata = @{ type = 'sharepoint_grounding' }
}
}
}
)
}
$tmp = New-TemporaryFile
($batch | ConvertTo-Json -Depth 20) | Set-Content -LiteralPath $tmp -Encoding utf8NoBOM
az rest --method post --url "https://management.azure.com/batch?api-version=${armBatchApiVersion}" --body "@$($tmp.FullName)" --headers 'Content-Type=application/json' --output jsoncSet the project endpoint:
$endpoint = "https://${accountName}.services.ai.azure.com/api/projects/${projectName}"List connections:
az rest --method get --url "${endpoint}/connections?api-version=${foundryApiVersion}" --resource 'https://ai.azure.com' --output jsoncGet a single connection:
az rest --method get --url "${endpoint}/connections/${connectionName}?api-version=${foundryApiVersion}" --resource 'https://ai.azure.com' --output jsoncaz rest --method post --url "${endpoint}/connections/${connectionName}/getConnectionWithCredentials?api-version=${foundryApiVersion}" --resource 'https://ai.azure.com' --output jsoncThe response can include credential fields (for example, the configured SharePoint URL) along with credentials.type.
$url = "https://management.azure.com/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.CognitiveServices/accounts/${accountName}/projects/${projectName}/connections/${connectionName}?api-version=${armApiVersion}"
az rest --method delete --url $urlVerify deletion:
# ARM should return 404 NotFound after deletion
az rest --method get --url $url --output jsonc
# Data plane list should no longer show the name
$endpoint = "https://${accountName}.services.ai.azure.com/api/projects/${projectName}"
az rest --method get --url "${endpoint}/connections?api-version=${foundryApiVersion}" --resource 'https://ai.azure.com' --output jsoncThese notes are for the Microsoft SharePoint tool (preview) in Foundry Agent Service:
- The SharePoint tool supports configuring a single
site_urlvalue per connection (a SharePoint site or a SharePoint folder URL). In ARM, this shows up as a singlecredentials.keys.siteUrlfield. - The SharePoint tool only supports user identity authentication (no service principal / SPN auth).
- Your SharePoint site/folder and the Foundry agent must be in the same tenant.
- Supported document types include
.pdf,.docx,.ppt,.txt,.aspx.
Reference: Use the Microsoft SharePoint tool (preview)
- If ARM returns a 400 about deserialization, use
credentials.keys.siteUrl(camelCase) in the ARM PUT payload. - For
*.services.ai.azure.comcalls, pass--resource 'https://ai.azure.com'.