-
Notifications
You must be signed in to change notification settings - Fork 2k
Python: Update FHA with toolbox sample with more auth methods #6713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
TaoChenOSU
wants to merge
3
commits into
microsoft:main
Choose a base branch
from
TaoChenOSU:update/fha-toolbox-sample-with-auth
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
2 changes: 1 addition & 1 deletion
2
python/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/.env.example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| FOUNDRY_PROJECT_ENDPOINT="..." | ||
| AZURE_AI_MODEL_DEPLOYMENT_NAME="..." | ||
| FOUNDRY_TOOLBOX_ENDPOINT="..." | ||
| TOOLBOX_ENDPOINT="..." |
261 changes: 229 additions & 32 deletions
261
...samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/README.md
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
...on/samples/04-hosting/foundry-hosted-agents/responses/04_foundry_toolbox/requirements.txt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| agent-framework | ||
| agent-framework-foundry-hosting | ||
| mcp>=1.24.0,<2 | ||
| agent-framework-foundry | ||
| agent-framework-foundry-hosting |
105 changes: 105 additions & 0 deletions
105
...ng/foundry-hosted-agents/responses/04_foundry_toolbox/scripts/list-foundry-connectors.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| #!/usr/bin/env pwsh | ||
| <# | ||
| .SYNOPSIS | ||
| List Foundry Tools Catalog connectors, or fetch full details for one connector. | ||
|
|
||
| .DESCRIPTION | ||
| Queries the Azure AI Foundry Tools Catalog (asset-gallery) connectors registry. | ||
| - With no -ConnectorName: lists all connectors (name, title, detected auth type). | ||
| - With -ConnectorName: prints the full JSON details for that connector. | ||
|
|
||
| A bearer token for https://ai.azure.com is required. It is read from the | ||
| -Token parameter, then the CATALOG_TOKEN environment variable, and finally | ||
| acquired automatically via 'az account get-access-token' (requires 'az login'). | ||
|
|
||
| .EXAMPLE | ||
| ./list-foundry-connectors.ps1 | ||
| Lists all connectors. | ||
|
|
||
| .EXAMPLE | ||
| ./list-foundry-connectors.ps1 -ConnectorName a365outlookmailmcp | ||
| Prints full details for the Work IQ Mail MCP connector. | ||
|
|
||
| .EXAMPLE | ||
| ./list-foundry-connectors.ps1 -PageSize 2000 | ||
| Lists more connectors in a single page. | ||
| #> | ||
| [CmdletBinding()] | ||
| param( | ||
| # annotations/name of a connector to fetch full details for. Omit to list all. | ||
| [string]$ConnectorName, | ||
| # Azure ML region host prefix. | ||
| [string]$Region = "eastus", | ||
| # Number of results to request in one page. | ||
| [int]$PageSize = 100, | ||
| # Catalog bearer token (audience https://ai.azure.com). Defaults to $env:CATALOG_TOKEN, else acquired via az. | ||
| [string]$Token = $env:CATALOG_TOKEN | ||
| ) | ||
|
|
||
| $ErrorActionPreference = "Stop" | ||
|
|
||
| if (-not $Token) { | ||
| Write-Verbose "No token supplied; acquiring via 'az account get-access-token'..." | ||
| $Token = az account get-access-token --resource https://ai.azure.com --query accessToken -o tsv | ||
| } | ||
| if (-not $Token) { | ||
| throw "Failed to acquire a catalog token. Run 'az login', or pass -Token / set `$env:CATALOG_TOKEN." | ||
| } | ||
|
|
||
| $uri = "https://$Region.api.azureml.ms/asset-gallery/v1.0/tools" | ||
| $headers = @{ | ||
| "Authorization" = "Bearer $Token" | ||
| "Content-Type" = "application/json" | ||
| "x-ms-user-agent" = "AzureMachineLearningWorkspacePortal/12.0" | ||
| } | ||
|
|
||
| $filters = [System.Collections.ArrayList]@( | ||
| @{ field = "entityContainerId"; operator = "eq"; values = @("connectors-registry-prod-bl") } | ||
| @{ field = "type"; operator = "eq"; values = @("tools") } | ||
| @{ field = "kind"; operator = "eq"; values = @("Versioned") } | ||
| @{ field = "labels"; operator = "eq"; values = @("latest") } | ||
| ) | ||
| if ($ConnectorName) { | ||
| [void]$filters.Add(@{ field = "annotations/name"; operator = "eq"; values = @($ConnectorName) }) | ||
| } | ||
|
|
||
| $body = @{ | ||
| freeTextSearch = "*" | ||
| filters = $filters | ||
| includeTotalResultCount = $true | ||
| pageSize = $PageSize | ||
| skip = 0 | ||
| } | ConvertTo-Json -Depth 10 | ||
|
|
||
| # The response can be several MB and may contain a property with an empty-string | ||
| # name, so read the raw content and parse with -AsHashtable. | ||
| $content = (Invoke-WebRequest -Method Post -Uri $uri -Headers $headers -Body $body).Content | ||
| $resp = $content | ConvertFrom-Json -AsHashtable -Depth 100 | ||
|
|
||
| if ($ConnectorName) { | ||
| if ($resp.totalCount -eq 0) { | ||
| Write-Warning "No connector found with annotations/name '$ConnectorName'." | ||
| return | ||
| } | ||
| $resp.value | ConvertTo-Json -Depth 100 | ||
| } | ||
| else { | ||
| Write-Host "Total connectors: $($resp.totalCount)" | ||
| $resp.value | ForEach-Object { | ||
| $params = $_.properties.'x-ms-connection-parameters' | ||
| $authType = if ($null -eq $params) { | ||
| "None" | ||
| } | ||
| else { | ||
| $types = $params.Values | ForEach-Object { $_.type } | ||
| if ($types -contains "oauthSetting") { "OAuth2" } | ||
| elseif ($types -contains "securestring") { "CustomKeys" } | ||
| else { "None" } | ||
| } | ||
| [pscustomobject]@{ | ||
| Name = $_.annotations.name | ||
| Title = $_.properties.title | ||
| Auth = $authType | ||
| } | ||
| } | Format-Table -AutoSize | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.