-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #156 from Azure-Samples/ap/docs-and-iaac
LGTM
- Loading branch information
Showing
7 changed files
with
512 additions
and
3 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# CLI scripts for creating the Azure resources needed for the workshop | ||
|
||
## Synopsis | ||
This folder contains a PowerShell script that will create the Azure resources needed for the workshop. The script will create a resource group for each of the workshop participants, and will create the required resources in each resource group. You will need to provide a subscription id, and optionally a resource group prefix, location, and the number of resource groups you want. The script will default to the values below if not provided. | ||
resourceGroupPrefix = "myagi-1-rg-" | ||
location = "eastus" | ||
resourceGroupCount = 1 | ||
|
||
|
||
## Steps | ||
1. Install Azure CLI (https://docs.microsoft.com/en-us/cli/azure/install-azure-cli), min version 2.53.0 | ||
2. Install PowerShell (https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.1) | ||
3. Change folder to `infrastructure/cli` | ||
4. Run | ||
``` | ||
./deploy.ps1 -resourceGroupPrefix "<myagi-3-rg->" -location "<eastus>" -resourceGroupCount "<1>" -subscriptionId "<your subscription id>" | ||
``` | ||
Note: Only subscriptionId is required, the rest are optional and will default to the values above if not provided. | ||
|
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,20 @@ | ||
|
||
param location string = resourceGroup().location | ||
param searchServiceName string | ||
|
||
|
||
param sku object = { | ||
name: 'standard' | ||
} | ||
|
||
resource searchService 'Microsoft.Search/searchServices@2021-04-01-Preview' = { | ||
name: searchServiceName | ||
location: location | ||
|
||
properties: { | ||
semanticSearch: 'free' | ||
} | ||
sku:sku | ||
|
||
} | ||
|
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,238 @@ | ||
param ( | ||
[string]$resourceGroupPrefix = "miyagi1", | ||
[string]$location = "eastus", | ||
[string]$resourceGroupCount = 1, | ||
[string]$subscriptionId = "SubscriptionId is required" | ||
) | ||
|
||
# print variables | ||
|
||
Write-Host "resourceGroupPrefix: $resourceGroupPrefix" | ||
Write-Host "location: $location" | ||
Write-Host "resourceGroupCount: $resourceGroupCount" | ||
Write-Host "subscriptionId: $subscriptionId" | ||
|
||
# set rgIndex to resourceGroupCount | ||
|
||
$rgIndex = $resourceGroupCount | ||
|
||
# set all these to false the first time you run this script. After that you can set them to true to skip creating resources that already exist | ||
$skipRg = "false" | ||
$skipOpenAI = "false" | ||
$skipEmbeddingModelDeployment = "false" | ||
$skipCompletionModelDeployment = "false" | ||
$skipcognitiveSearch = "false" | ||
$skipCosmosDB = "false" | ||
$skipBlobStorage = "false" | ||
$skipAzureContainerApps = "false" | ||
$skipAzureContainerRegistry = "false" | ||
$skipAPIM = "false" | ||
|
||
# strip - from resourceGroupPrefix | ||
|
||
$resourceGroupPrefix = $resourceGroupPrefix.Replace("-",""); | ||
|
||
# create resource groups in a loop for rgIndex | ||
# if skipRg is true, skip creating resource group | ||
|
||
if ($skipRg -eq "true") { | ||
Write-Host "Skipping resource group creation" | ||
} | ||
else { | ||
|
||
for ($i = 1; $i -le $rgIndex; $i++) { | ||
Write-Host "Creating resource group $resourceGroupPrefix-rg-$i in $location" | ||
az group create --name "$resourceGroupPrefix-rg-$i" --location $location | ||
} | ||
} | ||
|
||
# create Azure Open AI service resource for each resource group | ||
|
||
for ($i = 1; $i -le $rgIndex; $i++) { | ||
# if skipRg is true, skip creating resource group | ||
if ($skipOpenAI -eq "true") { | ||
Write-Host "Skipping OpenAI resource creation" | ||
} | ||
else { | ||
Write-Host "Creating Azure Open AI service resource named $resourceGroupPrefix-OpenAIService-$i in $resourceGroupPrefix-rg-$i" | ||
|
||
az cognitiveservices account create ` | ||
--name "$resourceGroupPrefix-OpenAIService-$i" ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--location $location ` | ||
--kind "OpenAI" ` | ||
--sku "s0" ` | ||
--subscription $subscriptionId | ||
} | ||
|
||
# if skipEmbeddingModelDeployment is true, skip embedding model deployment | ||
|
||
if ($skipEmbeddingModelDeployment -eq "true") { | ||
Write-Host "Skipping embedding model deployment" | ||
} | ||
else { | ||
# deploy embedding model | ||
|
||
Write-Host "Deploying embedding model $resourceGroupPrefix-EmbeddingModel-$i" | ||
|
||
az cognitiveservices account deployment create ` | ||
--name "$resourceGroupPrefix-OpenAIService-$i" ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--deployment-name "$resourceGroupPrefix-EmbeddingModel-$i" ` | ||
--model-name text-embedding-ada-002 ` | ||
--model-version "2" ` | ||
--model-format "OpenAI" ` | ||
--scale-capacity "20" ` | ||
--capacity "20" | ||
|
||
} | ||
|
||
# if skipCompletionModelDeployment is true, skip completion model deployment | ||
|
||
if ($skipCompletionModelDeployment -eq "true") { | ||
Write-Host "Skipping completion model deployment" | ||
} | ||
else { | ||
# deploy completion model | ||
|
||
Write-Host "Deploying completion model $resourceGroupPrefix-CompletionModel-$i" | ||
|
||
az cognitiveservices account deployment create ` | ||
--name "$resourceGroupPrefix-OpenAIService-$i" ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--deployment-name "$resourceGroupPrefix-CompletionModel-$i" ` | ||
--model-name "gpt-35-turbo" ` | ||
--model-version "0613" ` | ||
--model-format "OpenAI" ` | ||
--capacity "30" | ||
|
||
} | ||
|
||
# if skipCosmosDB is false, create CosmosDB account called miyagi with a container called recommendations | ||
|
||
if ($skipCosmosDB -eq "true") { | ||
Write-Host "Skipping CosmosDB account creation" | ||
} | ||
else { | ||
Write-Host "Creating CosmosDB account $resourceGroupPrefix-cosmos-$i in $resourceGroupPrefix-rg-$i" | ||
|
||
az cosmosdb create ` | ||
--name "$resourceGroupPrefix-cosmos-$i" ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--kind "GlobalDocumentDB" ` | ||
--subscription $subscriptionId | ||
|
||
Write-Host "Creating CosmosDB database $resourceGroupPrefix-cosmos-$i in $resourceGroupPrefix-rg-$i" | ||
|
||
az cosmosdb sql database create ` | ||
--account-name "$resourceGroupPrefix-cosmos-$i" ` | ||
--name "miyagi" ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--subscription $subscriptionId | ||
|
||
Write-Host "Creating CosmosDB container $resourceGroupPrefix-cosmos-$i in $resourceGroupPrefix-rg-$i" | ||
|
||
az cosmosdb sql container create ` | ||
--account-name "$resourceGroupPrefix-cosmos-$i" ` | ||
--database-name "miyagi" ` | ||
--name "recommendations" ` | ||
--partition-key-path "/partitionKey" ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--subscription $subscriptionId | ||
} | ||
|
||
# if skipBlobStorage is false, create blob storage account with a container called miyagi | ||
|
||
if ($skipBlobStorage -eq "true") { | ||
Write-Host "Skipping blob storage account creation" | ||
} | ||
else { | ||
|
||
$storageaccount = -join($resourceGroupPrefix,"blobstorge",$i) | ||
Write-Host "Creating blob storage account $storageaccount in $resourceGroupPrefix-rg-$i" | ||
|
||
az storage account create ` | ||
--name $storageaccount ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--location $location ` | ||
--sku "Standard_LRS" ` | ||
--subscription $subscriptionId | ||
|
||
Write-Host "Creating blob storage container miyagi in $resourceGroupPrefix-rg-$i" | ||
|
||
az storage container create ` | ||
--name "miyagi" ` | ||
--account-name $storageaccount ` | ||
--subscription $subscriptionId | ||
} | ||
|
||
# if skipAzureContainerRegistry is false, create Azure Container Registry called miyagi | ||
|
||
if ($skipAzureContainerRegistry -eq "true") { | ||
Write-Host "Skipping Azure Container Registry creation" | ||
} | ||
else { | ||
|
||
$containerregistry = -join($resourceGroupPrefix,"acr",$i) | ||
Write-Host "Creating Azure Container Registry $containerregistry in $resourceGroupPrefix-rg-$i" | ||
|
||
az acr create ` | ||
--name $containerregistry ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--location $location ` | ||
--sku "Basic" ` | ||
--subscription $subscriptionId | ||
} | ||
|
||
# if skipAzureContainerApps is false, create Azure Container Apps with a container called miyagi | ||
|
||
if ($skipAzureContainerApps -eq "true") { | ||
Write-Host "Skipping Azure Container App creation" | ||
} | ||
else { | ||
|
||
$containerapp = -join($resourceGroupPrefix,"miyagi",$i) | ||
Write-Host "Creating Azure Container Apps $containerapp in $resourceGroupPrefix-rg-$i" | ||
|
||
az containerapp up --name $containerapp ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--location centralus ` | ||
--environment "$resourceGroupPrefix-env" ` | ||
--image mcr.microsoft.com/azuredocs/containerapps-helloworld:latest ` | ||
--target-port 80 ` | ||
--ingress external ` | ||
--query properties.configuration.ingress.fqdn ` | ||
|
||
|
||
|
||
|
||
} | ||
|
||
# if skipcognitiveSearch is false, create cognitive search service with semantic search capability | ||
|
||
if ($skipcognitiveSearch -eq "true") { | ||
Write-Host "Skipping cognitive search service creation" | ||
} | ||
else { | ||
|
||
Write-Host "Creating cognitive search service $resourceGroupPrefix-acs-$i in $resourceGroupPrefix-rg-$i" | ||
|
||
az deployment group create ` | ||
--resource-group "$resourceGroupPrefix-rg-$i" ` | ||
--template-file "bicep/search-service.bicep" ` | ||
--parameters "searchServiceName=$resourceGroupPrefix-acs-$i" | ||
|
||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
} | ||
|
||
|
||
|
||
|
Oops, something went wrong.