0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Foundry BYO VNet + Private Endpoints plus tools のデプロイ(Template19)

0
Last updated at Posted at 2026-06-07

以下のGitHubにあるテンプレートを確認してみましたのでその記録です。Ubuntuでテンプレートをダウンロードして動かしています。

このテンプレートの位置づけです。

Standard Agent Setup with E2E Network Isolation with Tools behind VNET

このテンプレートは Foundry Agent Service を、Bring Your Own Virtual Network (BYO VNet) + 3 サブネット(Agent / PE / MCP)+ Private Endpoint で完全閉域化する。Template 15 と同じ閉域化に加え、MCP サーバー・OpenAPI ツール・Azure Functions・A2A エージェントを VNet 内にホストできる 点が 15 との差。[^1]

テンプレ 用途 主な差分
11 Basic + VNet injection BYO Storage/Cosmos/Search なし、PE×1、DNS Zone×3
15 Standard + 完全閉域 BYO Storage/Cosmos/Search、PE×4、DNS Zone×7
19(本テンプレ) 15 + ツールも VNet 内 15 と同等 + MCP サブネット追加(3 サブネット構成)
18 Managed VNet (preview) Microsoft 管理 VNet(BYO VNet 不要)

ルートのBicepを使っただけだと、toolはデプロイされず、mcp用のサブネットは作られるので、このテンプレートと別にAzure Container Apps を VNet 内に建てる必要があります。

エラーが出て少し改修している点もあるため、同じことをやっても、同じ形でデプロイされません。
どんな形でAzure リソースが作成されるかを残すのがこの記事の主目的です

Steps

0. 事前準備

azd で実行できるようにazure.yamlを作成。

azure.yaml
name: foundry-19-byo-vnet
metadata:
  template: foundry-19-byo-vnet

infra:
  provider: bicep
  path: ./template-19
  module: main

1. ログイン

最初はログイン。

az login
azd auth login

その後に provider register。

az provider register --namespace 'Microsoft.KeyVault'
az provider register --namespace 'Microsoft.CognitiveServices'
az provider register --namespace 'Microsoft.Storage'
az provider register --namespace 'Microsoft.Search'
az provider register --namespace 'Microsoft.Network'
az provider register --namespace 'Microsoft.App'
az provider register --namespace 'Microsoft.ContainerService'

# 🔴 README に書いていないが必要(テンプレ内で Cosmos DB を作るため)
az provider register --namespace 'Microsoft.DocumentDB'

結果確認。

az provider show -n Microsoft.KeyVault --query registrationState -o tsv
az provider show -n Microsoft.CognitiveServices --query registrationState -o tsv
az provider show -n Microsoft.Storage --query registrationState -o tsv
az provider show -n Microsoft.Search --query registrationState -o tsv
az provider show -n Microsoft.Network --query registrationState -o tsv
az provider show -n Microsoft.App --query registrationState -o tsv
az provider show -n Microsoft.ContainerService --query registrationState -o tsv
az provider show -n Microsoft.DocumentDB --query registrationState -o tsv

2. 環境作成

新しい環境作成。

cd <root folder>
azd env new foundry19jpe

上記を実行すると以下のフォルダとファイルが作られる。このfoundry19jpeの単位で環境を分けます。

.azure/
└── foundry19jpe/
    ├── .env
    └── config.json

3. デプロイ

azd upとりあえず成功。デプロイは成功しているので"event-postdeploy"に関しては気にしないで行きます。

$ azd up
? Select an Azure Subscription to use:  1. ******
? Pick a resource group to use: 1. Create a new resource group
? Select a location to create the resource group in: 10. (Asia Pacific) Japan East (japaneast)
? Enter a name for the new resource group: rg-foundry19-05-jpe

Provisioning and deploying (azd up)
Packaging overlaps with provisioning for faster execution.

  You can view detailed progress in the Azure Portal:
  https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/overview/id/%2Fsubscriptions%2F  略
  
  () Done: Virtual Network: agent-vnet (3.956s)
  () Done: Storage account: f19demoalpkstorage (28.917s)
  () Done: Search service: f19demoalpksearch (6m54.059s)
  () Done: Azure Cosmos DB: f19demoalpkcosmosdb (1m47.374s)
  () Done: Foundry: f19demoalpk (5m27.686s)
  () Done: Azure AI Services Model Deployment: f19demoalpk/gpt-4o-mini (5.589s)
  () Done: Private Endpoint: f19demoalpksearch-private-endpoint (28.377s)
  () Done: Private Endpoint: f19demoalpk-private-endpoint (33.133s)
  () Done: Private Endpoint: f19demoalpkstorage-private-endpoint (30.61s)
  () Done: Private Endpoint: f19demoalpkcosmosdb-private-endpoint (8m0.728s)
  () Done: Foundry project: f19demoalpk/projectalpk (6.934s)
  () Done: Foundry project connection: f19demoalpk/projectalpk/f19demoalpkcosmosdb (1.977s)
  () Done: Foundry project connection: f19demoalpk/projectalpk/f19demoalpksearch (5.506s)
  () Done: Foundry project connection: f19demoalpk/projectalpk/f19demoalpkstorage (4.037s)

ERROR: step "event-postdeploy" failed: extension azure.ai.agents project hook postdeploy failed: AZURE_AI_PROJECT_ENDPOINT is not set in the environment

作成された結果

リソース一覧

$ az resource list --resource-group rg-foundry19-05-jpe --output table --query "[].{Type:type
, Name:name}"
Type                                                   Name
-----------------------------------------------------  -----------------------------------------------------------------------------------------
Microsoft.DocumentDB/databaseAccounts                  f19demoalpkcosmosdb
Microsoft.Storage/storageAccounts                      f19demoalpkstorage
Microsoft.Search/searchServices                        f19demoalpksearch
Microsoft.Network/virtualNetworks                      agent-vnet
Microsoft.CognitiveServices/accounts                   f19demoalpk
Microsoft.Network/privateEndpoints                     f19demoalpksearch-private-endpoint
Microsoft.Network/privateEndpoints                     f19demoalpk-private-endpoint
Microsoft.Network/privateEndpoints                     f19demoalpkstorage-private-endpoint
Microsoft.Network/privateEndpoints                     f19demoalpkcosmosdb-private-endpoint
Microsoft.Network/privateDnsZones                      privatelink.blob.core.windows.net
Microsoft.Network/privateDnsZones                      privatelink.openai.azure.com
Microsoft.Network/privateDnsZones                      privatelink.documents.azure.com
Microsoft.Network/privateDnsZones                      privatelink.search.windows.net
Microsoft.Network/privateDnsZones                      privatelink.cognitiveservices.azure.com
Microsoft.Network/privateDnsZones                      privatelink.services.ai.azure.com
Microsoft.Network/networkInterfaces                    f19demoalpkstorage-private-endpoint.nic.59a383d3-68d0-45dc-b20b-2a7f13f5d2a5
Microsoft.Network/networkInterfaces                    f19demoalpk-private-endpoint.nic.bd2bd4fb-d4f9-42f2-a602-4ae5c78c89bf
Microsoft.Network/networkInterfaces                    f19demoalpkcosmosdb-private-endpoint.nic.b8131940-5e39-4dbc-bc67-c76a11b1d4bb
Microsoft.Network/networkInterfaces                    f19demoalpksearch-private-endpoint.nic.6c104672-a6ed-4d8d-ba8e-a5e0c90b4fe7
Microsoft.Network/privateDnsZones/virtualNetworkLinks  privatelink.cognitiveservices.azure.com/privatelink-cognitiveservices-azure-com-alpk-link
Microsoft.Network/privateDnsZones/virtualNetworkLinks  privatelink.blob.core.windows.net/privatelink-blob-core-windows-net-alpk-link
Microsoft.Network/privateDnsZones/virtualNetworkLinks  privatelink.search.windows.net/privatelink-search-windows-net-alpk-link
Microsoft.Network/privateDnsZones/virtualNetworkLinks  privatelink.documents.azure.com/privatelink-documents-azure-com-alpk-link
Microsoft.Network/privateDnsZones/virtualNetworkLinks  privatelink.openai.azure.com/privatelink-openai-azure-com-alpk-link
Microsoft.Network/privateDnsZones/virtualNetworkLinks  privatelink.services.ai.azure.com/privatelink-services-ai-azure-com-alpk-link
Microsoft.CognitiveServices/accounts/projects          f19demoalpk/projectalpk

VNet

アドレス空間

image.png

サブネット

mcp-subnetは現時点では特に使われておらず、Azure Container Apps を VNet 内に建てて、Foundry Agent から Private Endpoint 経由で呼ぶ時だけ使います。

image.png

接続デバイス

同じIDにCosmos DBが2つあるのはプライマリとセカンダリの2種類あるから。
image.png

プライベートDNSゾーン。

Foundry関連が3つ。これは、Foundryが3つのFQDNを持つから。
image.png

プライベートエンドポイント

image.png

Foundry Dependenciesのリソース

  • 基本、Public Network は無効になり、PEとひもづいている
  • システム割当Managed ID が ON(Cosmos DBはOFF)
  • Foundry Project の Managed IDへのRBACが割当
  • 診断設定なし(Log Analytics Workspaceない)

Cosmos

容量モード は 「プロビジョニング済みスループット」
自動で以下のコンテナ、データベースを作ってRUの設定。
image.png

Geo冗長バックアップ
image.png

AI Search

Standard で作成されている。他は特筆事項なし

Storage Account

  • 階層型名前空間は無効のStorageV2 (汎用 v2)
  • ゾーン冗長ストレージ (ZRS)
  • キーアクセス無効(Subscriptionの設定でそうなっているだけかもしれない)

Foundry

キーアクセス無効済
Connectionが3つ。
image.png

失敗談

リソース枯渇

何かのリソース作ろうとしたときにリージョン枯渇で失敗。

$ azd up

Let's get your development environment ready.

Discover and install Azure development tools such as Azure CLI, GitHub Copilot CLI, and Azure AI extensions.
To skip this check, set AZD_SKIP_FIRST_RUN=true or run azd config set tool.firstRunCompleted true.

? Would you like to check your Azure development tools?: [Y/n] Yes
✓ Azure CLI (2.81.0)
  ✓ GitHub Copilot CLI (1.0.57)
  ✓ Azure Tools VS Code Extension (0.12.5)
  ✓ Bicep VS Code Extension (0.43.8)
  ○ GitHub Copilot Chat VS Code Extension — not installed
  ○ Azure MCP Server — not installed
  ✓ azd AI Agent Extensions (0.1.27-preview)

All recommended tools are installed. You're all set!
? Select an Azure Subscription to use:  1. *****
? Select an Azure location to use: 10. (Asia Pacific) Japan East (japaneast)
? Pick a resource group to use: 1. Create a new resource group
? Enter a name for the new resource group: rg-foundry19jpe

Provisioning and deploying (azd up)
Packaging overlaps with provisioning for faster execution.

  You can view detailed progress in the Azure Portal:
  https://portal.azure.com/#view/HubsExtension/DeploymentDetailsBlade/~/overview/id/<略>

  (x) Failed: Search service: contosorfrwsearch (2.681s)
  () Done: Virtual Network: agent-vnet (7.979s)
  () Done: Storage account: contosorfrwstorage (22.791s)
  () Done: Azure Cosmos DB: contosorfrwcosmosdb (1m9.764s)
  () Done: Foundry: contosorfrw (4m20.712s)
  () Done: Azure AI Services Model Deployment: contosorfrw/gpt-4o-mini (3.734s)

ERROR: A resource with this name already exists or is in a conflicting state.

Suggestion: Check for existing or soft-deleted resources in the Azure portal.

deployment failed: step "provision" failed: deploying layer provision: error deploying infrastructure: deploying to resource group: 

Deployment Error Details:
InsufficientResourcesAvailable: The region 'eastus2' is currently out of the resources required to provision new services. Try creating the service in another region. RequestId: 7e7e4af2-8753-97b5-68d0-b31dab8f8543

パージ失敗

azd down --purge --force

azd --purgeのバグで消せなかったので、Foundryだけ手で消して、もう一度azd down --purge --force

$ azd down --purge --force

Deleting all resources and deployed code on Azure (azd down)
Local application code is not deleted when running 'azd down'.

  |=      | Discovering resources to delete...

ERROR: deleting infrastructure: error deleting Azure resources: getting cognitive accounts to purge: getting cognitive account contosorfrw: unmarshalling type *armcognitiveservices.Account: unmarshalling type *armcognitiveservices.Account: struct field Properties: unmarshalling type *armcognitiveservices.AccountProperties: struct field NetworkInjections: unmarshalling type *armcognitiveservices.NetworkInjections: json: cannot unmarshal array into Go value of type map[string]json.RawMessage

post deployに向けたエラー

Deploy自体は成功しているので無視。

ERROR: step "event-postdeploy" failed: extension azure.ai.agents project hook postdeploy failed: AZURE_AI_PROJECT_ENDPOINT is not set in the environment
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?