-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
1,227 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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,50 @@ | ||
# Deploying the Solution | ||
|
||
## Deploying the infrastructure | ||
|
||
Run the following commands to deploy the infrastructure: | ||
|
||
```bash | ||
cd infra | ||
terraform init | ||
terraform apply | ||
``` | ||
|
||
## Manual steps | ||
|
||
> This is temporal | ||
Clone the GitHub repository [cmendible/azure-search-openai-demo](https://github.com/cmendible/azure-search-openai-demo) and run the following commands to deploy the Azure Search Index and upload the sample documents: | ||
|
||
```bash | ||
git clone https://github.com/cmendible/azure-search-openai-demo.git | ||
cd azure-search-openai-demo | ||
git checkout k8s | ||
|
||
export AZURE_PRINCIPAL_ID="<principal id>" | ||
export AZURE_RESOURCE_GROUP="<resource group>" | ||
export AZURE_SUBSCRIPTION_ID="<subscription id>" | ||
export AZURE_TENANT_ID="<azure tenant id>" | ||
export AZURE_STORAGE_ACCOUNT="<storage account name>" | ||
export AZURE_STORAGE_CONTAINER="content" | ||
export AZURE_SEARCH_SERVICE="<search service name>" | ||
export OPENAI_HOST="azure" | ||
export AZURE_OPENAI_SERVICE="<openai service name>" | ||
export OPENAI_API_KEY="" | ||
export OPENAI_ORGANIZATION="" | ||
export AZURE_OPENAI_EMB_DEPLOYMENT="text-embedding-ada-002" | ||
export AZURE_OPENAI_EMB_MODEL_NAME="text-embedding-ada-002" | ||
export AZURE_SEARCH_INDEX="gptkbindex" | ||
``` | ||
|
||
Login to Azure: | ||
|
||
```bash | ||
azd auth login --client-id <client-id> --client-secret <client-password> --tenant-id <tenant-id> | ||
``` | ||
|
||
Deploy the Azure Search Index and upload the sample documents: | ||
|
||
```bash | ||
./scripts/prepdocs.sh | ||
``` |
This file contains 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,157 @@ | ||
data "azurerm_subscription" "current" {} | ||
|
||
resource "random_id" "random" { | ||
byte_length = 8 | ||
} | ||
|
||
resource "azurerm_resource_group" "rg" { | ||
name = var.resource_group_name | ||
location = var.location | ||
} | ||
|
||
locals { | ||
name_sufix = substr(lower(random_id.random.hex), 1, 4) | ||
storage_account_name = "${var.storage_account_name}${local.name_sufix}" | ||
} | ||
|
||
module "vnet" { | ||
source = "./modules/vnet" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
virtual_network_name = var.virtual_network_name | ||
} | ||
|
||
module "apim" { | ||
source = "./modules/apim" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
apim_name = var.apim_name | ||
apim_subnet_id = module.vnet.apim_subnet_id | ||
publisher_name = var.publisher_name | ||
publisher_email = var.publisher_email | ||
} | ||
|
||
module "mi" { | ||
source = "./modules/mi" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
managed_identity_name = var.managed_identity_name | ||
} | ||
|
||
resource "azurerm_role_assignment" "id_reader" { | ||
scope = azurerm_resource_group.rg.id | ||
role_definition_name = "Reader" | ||
principal_id = module.mi.principal_id | ||
} | ||
|
||
module "search" { | ||
source = "./modules/search" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
search_name = var.search_name | ||
principal_id = module.mi.principal_id | ||
} | ||
|
||
module "form_recognizer" { | ||
source = "./modules/form" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
form_recognizer_name = var.form_recognizer_name | ||
} | ||
|
||
module "log" { | ||
source = "./modules/log" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
log_name = var.log_name | ||
} | ||
|
||
module "appi" { | ||
source = "./modules/appi" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
appi_name = var.apim_name | ||
log_id = module.log.log_id | ||
} | ||
|
||
module "st" { | ||
source = "./modules/st" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
storage_account_name = local.storage_account_name | ||
principal_id = module.mi.principal_id | ||
} | ||
|
||
module "openai" { | ||
source = "./modules/openai" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_name = azurerm_resource_group.rg.name | ||
secondary_location = var.secondary_location | ||
azopenai_name = var.azopenai_name | ||
principal_id = module.mi.principal_id | ||
} | ||
|
||
module "cae" { | ||
source = "./modules/cae" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_id = azurerm_resource_group.rg.id | ||
cae_name = var.cae_name | ||
cae_subnet_id = module.vnet.cae_subnet_id | ||
log_workspace_id = module.log.log_workspace_id | ||
log_key = module.log.log_key | ||
appi_key = module.appi.appi_key | ||
} | ||
|
||
module "ca_back" { | ||
source = "./modules/ca-back" | ||
location = azurerm_resource_group.rg.location | ||
resource_group_id = azurerm_resource_group.rg.id | ||
ca_name = var.ca_back_name | ||
cae_id = module.cae.cae_id | ||
managed_identity_id = module.mi.mi_id | ||
chat_gpt_deployment = module.openai.gpt_deployment_name | ||
chat_gpt_model = module.openai.gpt_deployment_name | ||
embeddings_deployment = module.openai.embedding_deployment_name | ||
embeddings_model = module.openai.embedding_deployment_name | ||
storage_account_name = module.st.storage_account_name | ||
storage_container_name = module.st.storage_container_name | ||
search_service_name = module.search.search_service_name | ||
search_index_name = module.search.search_index_name | ||
openai_service_name = module.openai.openai_service_name | ||
tenant_id = data.azurerm_subscription.current.tenant_id | ||
managed_identity_client_id = module.mi.client_id | ||
} | ||
|
||
# module "ca_webapi" { | ||
# source = "./modules/ca-webapi" | ||
# location = azurerm_resource_group.rg.location | ||
# resource_group_id = azurerm_resource_group.rg.id | ||
# ca_name = var.ca_webapi_name | ||
# cae_id = module.cae.cae_id | ||
# cae_default_domain = module.cae.defaultDomain | ||
# ca_webapp_name = var.ca_webapp_name | ||
# managed_identity_id = module.mi.mi_id | ||
# chat_gpt_deployment = module.openai.gpt_deployment_name | ||
# chat_gpt_model = module.openai.gpt_deployment_name | ||
# embeddings_deployment = module.openai.embedding_deployment_name | ||
# embeddings_model = module.openai.embedding_deployment_name | ||
# storage_account_name = module.st.storage_account_name | ||
# storage_container_name = module.st.storage_container_name | ||
# search_service_name = module.search.search_service_name | ||
# search_index_name = module.search.search_index_name | ||
# openai_service_name = module.openai.openai_service_name | ||
# tenant_id = data.azurerm_subscription.current.tenant_id | ||
# managed_identity_client_id = module.mi.client_id | ||
# } | ||
|
||
# module "ca_webapp" { | ||
# source = "./modules/ca-webapp" | ||
# location = azurerm_resource_group.rg.location | ||
# resource_group_id = azurerm_resource_group.rg.id | ||
# ca_name = var.ca_webapp_name | ||
# cae_id = module.cae.cae_id | ||
# managed_identity_id = module.mi.mi_id | ||
# tenant_id = data.azurerm_subscription.current.tenant_id | ||
# managed_identity_client_id = module.mi.client_id | ||
# backend_url = module.ca_webapi.fqdn | ||
# } |
This file contains 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,13 @@ | ||
resource "azurerm_api_management" "apim" { | ||
name = var.apim_name | ||
location = var.location | ||
resource_group_name = var.resource_group_name | ||
publisher_name = var.publisher_name | ||
publisher_email = var.publisher_email | ||
sku_name = "Developer_1" | ||
virtual_network_type = "External" # Use "Internal" for a fully private APIM | ||
|
||
virtual_network_configuration { | ||
subnet_id = var.apim_subnet_id | ||
} | ||
} |
This file contains 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,3 @@ | ||
output "apim_name" { | ||
value = azurerm_api_management.apim.name | ||
} |
This file contains 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,6 @@ | ||
variable "resource_group_name" {} | ||
variable "location" {} | ||
variable "apim_name" {} | ||
variable "publisher_name" {} | ||
variable "publisher_email" {} | ||
variable "apim_subnet_id" {} |
This file contains 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,7 @@ | ||
resource "azurerm_application_insights" "appinsights" { | ||
name = var.appi_name | ||
location = var.location | ||
resource_group_name = var.resource_group_name | ||
application_type = "web" | ||
workspace_id = var.log_id | ||
} |
This file contains 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,7 @@ | ||
output "appi_id" { | ||
value = azurerm_application_insights.appinsights.id | ||
} | ||
|
||
output "appi_key" { | ||
value = azurerm_application_insights.appinsights.instrumentation_key | ||
} |
This file contains 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,4 @@ | ||
variable "resource_group_name" {} | ||
variable "location" {} | ||
variable "appi_name" {} | ||
variable "log_id" {} |
Oops, something went wrong.