matching contributor guidelines
This commit is contained in:
parent
de72279095
commit
db1dc1b5bb
@ -1,20 +0,0 @@
|
||||
//Create an AI Services connection.
|
||||
resource "azapi_resource" "AIServicesConnection" {
|
||||
type = "Microsoft.MachineLearningServices/workspaces/connections@2024-04-01-preview"
|
||||
name = "Default_AIServices"
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
response_export_values = ["*"]
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
|
||||
resource "azurerm_resource_group" "default" {
|
||||
name = "rg-${var.names}"
|
||||
location = var.location
|
||||
}
|
||||
|
||||
resource "azurerm_storage_account" "default" {
|
||||
name = "${var.names}storage${random_string.suffix.result}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
account_tier = "Standard"
|
||||
account_replication_type = "GRS"
|
||||
allow_nested_items_to_be_public = false
|
||||
}
|
||||
|
||||
resource "azurerm_key_vault" "default" {
|
||||
name = "${var.names}keyvault${random_string.suffix.result}"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
sku_name = "standard"
|
||||
purge_protection_enabled = false
|
||||
}
|
||||
|
||||
// AzAPI AIServices
|
||||
resource "azapi_resource" "AIServicesResource"{
|
||||
type = "Microsoft.CognitiveServices/accounts@2023-10-01-preview"
|
||||
name = "${var.names}AIServicesResource"
|
||||
location = azurerm_resource_group.default.location
|
||||
parent_id = azurerm_resource_group.default.id
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
body = jsonencode({
|
||||
properties = {
|
||||
apiProperties = {
|
||||
statisticsEnabled = false
|
||||
}
|
||||
}
|
||||
kind = "AIServices"
|
||||
sku = {
|
||||
name = var.sku
|
||||
}
|
||||
})
|
||||
|
||||
response_export_values = ["*"]
|
||||
}
|
||||
|
||||
/* The following resources are OPTIONAL.
|
||||
resource "azurerm_application_insights" "default" {
|
||||
name = "${var.names}appinsights"
|
||||
location = azurerm_resource_group.default.location
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
application_type = "web"
|
||||
}
|
||||
|
||||
resource "azurerm_container_registry" "default" {
|
||||
name = "${var.names}contreg"
|
||||
resource_group_name = azurerm_resource_group.default.name
|
||||
location = azurerm_resource_group.default.location
|
||||
sku = "premium"
|
||||
admin_enabled = true
|
||||
}
|
||||
*/
|
@ -1,36 +0,0 @@
|
||||
resource "azapi_resource" "hub" {
|
||||
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
|
||||
name = "my-ai-hub"
|
||||
location = azurerm_resource_group.default.location
|
||||
parent_id = azurerm_resource_group.default.id
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
body = jsonencode({
|
||||
properties = {
|
||||
description = "This is my Azure AI hub"
|
||||
friendlyName = "My Hub"
|
||||
storageAccount = azurerm_storage_account.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
|
||||
containerRegistry = azurerm_container_registry.default.id
|
||||
*/
|
||||
|
||||
/*Optional: To enable Customer Managed Keys, the corresponding
|
||||
encryption = {
|
||||
status = var.encryption_status
|
||||
keyVaultProperties = {
|
||||
keyVaultArmId = azurerm_key_vault.default.id
|
||||
keyIdentifier = var.cmk_keyvault_key_uri
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
kind = "hub"
|
||||
})
|
||||
}
|
@ -1,32 +1,160 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = ">= 3.0, < 4.0"
|
||||
}
|
||||
azapi = {
|
||||
source = "azure/azapi"
|
||||
}
|
||||
}
|
||||
resource "random_pet" "rg_name" {
|
||||
prefix = var.resource_group_name_prefix
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {
|
||||
key_vault {
|
||||
recover_soft_deleted_key_vaults = false
|
||||
purge_soft_delete_on_destroy = false
|
||||
purge_soft_deleted_keys_on_destroy = false
|
||||
}
|
||||
resource_group {
|
||||
prevent_deletion_if_contains_resources = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azapi" {
|
||||
// RESOURCE GROUP
|
||||
resource "azurerm_resource_group" "rg" {
|
||||
location = var.resource_group_location
|
||||
name = random_pet.rg_name.id
|
||||
}
|
||||
|
||||
data "azurerm_client_config" "current" {
|
||||
}
|
||||
}
|
||||
|
||||
// STORAGE ACCOUNT
|
||||
resource "azurerm_storage_account" "default" {
|
||||
name = "${var.prefix}storage${random_string.suffix.result}"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
account_tier = "Standard"
|
||||
account_replication_type = "GRS"
|
||||
allow_nested_items_to_be_public = false
|
||||
}
|
||||
|
||||
// KEY VAULT
|
||||
resource "azurerm_key_vault" "default" {
|
||||
name = "${var.prefix}keyvault${random_string.suffix.result}"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
tenant_id = data.azurerm_client_config.current.tenant_id
|
||||
sku_name = "standard"
|
||||
purge_protection_enabled = false
|
||||
}
|
||||
|
||||
// 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
|
||||
parent_id = azurerm_resource_group.rg.id
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
body = jsonencode({
|
||||
name = "AIServicesResource${random_string.suffix.result}"
|
||||
properties = {
|
||||
//restore = true
|
||||
customSubDomainName = "${random_string.suffix.result}domain"
|
||||
apiProperties = {
|
||||
statisticsEnabled = false
|
||||
}
|
||||
}
|
||||
kind = "AIServices"
|
||||
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
|
||||
parent_id = azurerm_resource_group.rg.id
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
body = jsonencode({
|
||||
properties = {
|
||||
description = "This is my Azure AI hub"
|
||||
friendlyName = "My Hub"
|
||||
storageAccount = azurerm_storage_account.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
|
||||
containerRegistry = azurerm_container_registry.default.id
|
||||
*/
|
||||
|
||||
/*Optional: To enable Customer Managed Keys, the corresponding
|
||||
encryption = {
|
||||
status = var.encryption_status
|
||||
keyVaultProperties = {
|
||||
keyVaultArmId = azurerm_key_vault.default.id
|
||||
keyIdentifier = var.cmk_keyvault_key_uri
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
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
|
||||
parent_id = azurerm_resource_group.rg.id
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
body = jsonencode({
|
||||
properties = {
|
||||
description = "This is my Azure AI PROJECT"
|
||||
friendlyName = "My Project"
|
||||
hubResourceId = azapi_resource.hub.id
|
||||
}
|
||||
kind = "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}"
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
response_export_values = ["*"]
|
||||
}
|
||||
|
||||
/* The following resources are OPTIONAL.
|
||||
// APPLICATION INSIGHTS
|
||||
resource "azurerm_application_insights" "default" {
|
||||
name = "${var.prefix}appinsights${random_string.suffix.result}"
|
||||
location = azurerm_resource_group.rg.location
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
application_type = "web"
|
||||
}
|
||||
|
||||
// CONTAINER REGISTRY
|
||||
resource "azurerm_container_registry" "default" {
|
||||
name = "${var.prefix}contreg${random_string.suffix.result}"
|
||||
resource_group_name = azurerm_resource_group.rg.name
|
||||
location = azurerm_resource_group.rg.location
|
||||
sku = "premium"
|
||||
admin_enabled = true
|
||||
}
|
||||
*/
|
@ -1,5 +1,5 @@
|
||||
output "ResourceGroup" {
|
||||
value = azurerm_resource_group.default.id
|
||||
value = azurerm_resource_group.rg.id
|
||||
}
|
||||
|
||||
output "HubId" {
|
||||
@ -12,5 +12,4 @@ output "ProjectId" {
|
||||
|
||||
output "endpoint" {
|
||||
value = jsondecode(azapi_resource.AIServicesResource.output).properties.endpoint
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
resource "azapi_resource" "project" {
|
||||
type = "Microsoft.MachineLearningServices/workspaces@2024-04-01-preview"
|
||||
name = "my-ai-project"
|
||||
location = azurerm_resource_group.default.location
|
||||
parent_id = azurerm_resource_group.default.id
|
||||
|
||||
identity {
|
||||
type = "SystemAssigned"
|
||||
}
|
||||
|
||||
body = jsonencode({
|
||||
properties = {
|
||||
description = "This is my Azure AI PROJECT"
|
||||
friendlyName = "My Project"
|
||||
hubResourceId = azapi_resource.hub.id
|
||||
}
|
||||
kind = "project"
|
||||
})
|
||||
}
|
33
quickstart/101-ai-studio/providers.tf
Normal file
33
quickstart/101-ai-studio/providers.tf
Normal file
@ -0,0 +1,33 @@
|
||||
terraform {
|
||||
required_version = ">= 1.0"
|
||||
|
||||
required_providers {
|
||||
azurerm = {
|
||||
source = "hashicorp/azurerm"
|
||||
version = "~>3.0"
|
||||
}
|
||||
azapi = {
|
||||
source = "azure/azapi"
|
||||
}
|
||||
random = {
|
||||
source = "hashicorp/random"
|
||||
version = "~>3.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azurerm" {
|
||||
features {
|
||||
key_vault {
|
||||
recover_soft_deleted_key_vaults = false
|
||||
purge_soft_delete_on_destroy = false
|
||||
purge_soft_deleted_keys_on_destroy = false
|
||||
}
|
||||
resource_group {
|
||||
prevent_deletion_if_contains_resources = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "azapi" {
|
||||
}
|
@ -1,14 +1,19 @@
|
||||
// Names and Try are used for naming conventions in hub.tf and depende
|
||||
variable "names" {
|
||||
type = string
|
||||
description="This variable is used to name the hub, project, and dependent resources."
|
||||
default = "tftemplate"
|
||||
variable "resource_group_location" {
|
||||
type = string
|
||||
default = "eastus"
|
||||
description = "Location of the resource group."
|
||||
}
|
||||
|
||||
variable "location" {
|
||||
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 is the location for all resources"
|
||||
default = "East US 2"
|
||||
description="This variable is used to name the hub, project, and dependent resources."
|
||||
default = "ai"
|
||||
}
|
||||
|
||||
variable "sku" {
|
||||
@ -23,7 +28,7 @@ resource "random_string" "suffix" {
|
||||
upper = false
|
||||
}
|
||||
|
||||
/*Optional: For Customer Managed Keys, uncomment this part AND the corresponding section in hub.tf
|
||||
/*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."
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user