Skip to content

Commit

Permalink
initial put
Browse files Browse the repository at this point in the history
  • Loading branch information
TomArcherMsft committed Feb 21, 2025
1 parent 1a625d7 commit 94e9343
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 1,164 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Azure AI Studio
# Azure AI Foundry

This deployment configuration specifies an [Azure AI hub](https://learn.microsoft.com/en-us/azure/ai-studio/concepts/ai-resources),
and its associated resources including Azure Key Vault, Azure Storage. You can optionally provision and attach Azure Application Insights and Azure Container Registry.
This deployment configuration specifies an [Azure AI hub](https://learn.microsoft.com/en-us/azure/ai-studio/concepts/ai-resources), and its associated resources including Azure Key Vault, Azure Storage. You can optionally provision and attach Azure Application Insights and Azure Container Registry.

This configuration describes the minimal set of resources you require to get started with Azure AI Studio.
This configuration describes the minimal set of resources you require to get started with Azure AI Foundry.

## Resources

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resource "random_pet" "rg_name" {
// Resource group
resource "random_pet" "rg_name" {
prefix = var.resource_group_name_prefix
}

// RESOURCE GROUP
resource "azurerm_resource_group" "rg" {
location = var.resource_group_location
name = random_pet.rg_name.id
Expand All @@ -11,7 +11,7 @@ resource "azurerm_resource_group" "rg" {
data "azurerm_client_config" "current" {
}

// STORAGE ACCOUNT
// Storage Account
resource "azurerm_storage_account" "default" {
name = "${var.prefix}storage${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
Expand All @@ -21,7 +21,7 @@ resource "azurerm_storage_account" "default" {
allow_nested_items_to_be_public = false
}

// KEY VAULT
// Key Vault
resource "azurerm_key_vault" "default" {
name = "${var.prefix}keyvault${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
Expand All @@ -32,51 +32,51 @@ resource "azurerm_key_vault" "default" {
}

// AzAPI AIServices
resource "azapi_resource" "AIServicesResource"{
type = "Microsoft.CognitiveServices/accounts@2023-10-01-preview"
name = "AIServicesResource${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
resource "azapi_resource" "AIServicesResource" {
type = "Microsoft.CognitiveServices/accounts@2024-10-01"
name = "AIServicesResource${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
parent_id = azurerm_resource_group.rg.id

identity {
type = "SystemAssigned"
}

body = jsonencode({
body = {
name = "AIServicesResource${random_string.suffix.result}"
properties = {
//restore = true
customSubDomainName = "${random_string.suffix.result}domain"
apiProperties = {
statisticsEnabled = false
}
apiProperties = {
statisticsEnabled = false
}
}
kind = "AIServices"
sku = {
name = var.sku
name = var.sku
}
})
}

response_export_values = ["*"]
}

// Azure AI Hub
resource "azapi_resource" "hub" {
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
name = "${random_pet.rg_name.id}-aih"
location = azurerm_resource_group.rg.location
type = "Microsoft.MachineLearningServices/workspaces/connections@2024-10-01"
name = "${random_pet.rg_name.id}-aih"
location = azurerm_resource_group.rg.location
parent_id = azurerm_resource_group.rg.id

identity {
type = "SystemAssigned"
}

body = jsonencode({
body = {
properties = {
description = "This is my Azure AI hub"
friendlyName = "My Hub"
description = "This is my Azure AI hub"
friendlyName = "My Hub"
storageAccount = azurerm_storage_account.default.id
keyVault = azurerm_key_vault.default.id
keyVault = azurerm_key_vault.default.id

/* Optional: To enable these field, the corresponding dependent resources need to be uncommented.
applicationInsight = azurerm_application_insights.default.id
Expand All @@ -92,17 +92,17 @@ resource "azapi_resource" "hub" {
}
}
*/

}
kind = "hub"
})
}
}

// Azure AI Project
resource "azapi_resource" "project" {
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
name = "my-ai-project${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
name = "my-ai-project${random_string.suffix.result}"
location = azurerm_resource_group.rg.location
parent_id = azurerm_resource_group.rg.id

identity {
Expand All @@ -111,8 +111,8 @@ resource "azapi_resource" "project" {

body = jsonencode({
properties = {
description = "This is my Azure AI PROJECT"
friendlyName = "My Project"
description = "This is my Azure AI PROJECT"
friendlyName = "My Project"
hubResourceId = azapi_resource.hub.id
}
kind = "project"
Expand All @@ -121,22 +121,22 @@ resource "azapi_resource" "project" {

// AzAPI AI Services Connection
resource "azapi_resource" "AIServicesConnection" {
type = "Microsoft.MachineLearningServices/workspaces/connections@2024-04-01-preview"
name = "Default_AIServices${random_string.suffix.result}"
type = "Microsoft.MachineLearningServices/workspaces/connections@2024-04-01-preview"
name = "Default_AIServices${random_string.suffix.result}"
parent_id = azapi_resource.hub.id

body = jsonencode({
properties = {
category = "AIServices",
target = jsondecode(azapi_resource.AIServicesResource.output).properties.endpoint,
authType = "AAD",
isSharedToAll = true,
metadata = {
ApiType = "Azure",
ResourceId = azapi_resource.AIServicesResource.id
}
properties = {
category = "AIServices",
target = jsondecode(azapi_resource.AIServicesResource.output).properties.endpoint,
authType = "AAD",
isSharedToAll = true,
metadata = {
ApiType = "Azure",
ResourceId = azapi_resource.AIServicesResource.id
}
})
}
})
response_export_values = ["*"]
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ output "resource_group_name" {
}

output "workspace_name" {
value = azapi_resource.project.id
value = azapi_resource.project.id
}

output "endpoint" {
value = jsondecode(azapi_resource.AIServicesResource.output).properties.endpoint
value = azapi_resource.AIServicesResource.output
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
terraform {
required_version = ">= 1.0"

required_providers {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~>3.0"
version = "~>4.0"
}
azapi = {
source = "azure/azapi"
version = "~>2.0"
}
random = {
source = "hashicorp/random"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
variable "resource_group_location" {
type = string
default = "eastus"
description = "Location of the resource group."
}

variable "resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
}

variable "prefix" {
type = string
description="This variable is used to name the hub, project, and dependent resources."
default = "ai"
}

variable "sku" {
type = string
description = "The sku name of the Azure Analysis Services server to create. Choose from: B1, B2, D1, S0, S1, S2, S3, S4, S8, S9. Some skus are region specific. See https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-overview#availability-by-region"
default = "S0"
}

resource "random_string" "suffix" {
length = 4
special = false
upper = false
}

/*Optional: For Customer Managed Keys, uncomment this part AND the corresponding section in main.tf
variable "cmk_keyvault_key_uri" {
description = "Key vault uri to access the encryption key."
}
variable "encryption_status" {
description = "Indicates whether or not the encryption is enabled for the workspace."
default = "Enabled"
}
variable "resource_group_location" {
type = string
default = "eastus"
description = "Location of the resource group."
}

variable "resource_group_name_prefix" {
type = string
default = "rg"
description = "Prefix of the resource group name that's combined with a random ID so name is unique in your Azure subscription."
}

variable "prefix" {
type = string
description = "This variable is used to name the hub, project, and dependent resources."
default = "ai"
}

variable "sku" {
type = string
description = "The sku name of the Azure Analysis Services server to create. Choose from: B1, B2, D1, S0, S1, S2, S3, S4, S8, S9. Some skus are region specific. See https://docs.microsoft.com/en-us/azure/analysis-services/analysis-services-overview#availability-by-region"
default = "S0"
}

resource "random_string" "suffix" {
length = 4
special = false
upper = false
}

/*Optional: For Customer Managed Keys, uncomment this part AND the corresponding section in main.tf
variable "cmk_keyvault_key_uri" {
description = "Key vault uri to access the encryption key."
}
variable "encryption_status" {
description = "Indicates whether or not the encryption is enabled for the workspace."
default = "Enabled"
}
*/
Loading

0 comments on commit 94e9343

Please sign in to comment.