Skip to content

Commit 723d6e9

Browse files
sonwan2020rotycenh
andauthored
script to prepare the lab environment, subscription / extension / azure-resource (#176)
## Purpose 1. add prepare tools to accelerate the time costs 2. more regional adjustments ## Does this introduce a breaking change? <!-- Mark one with an "x". --> ``` [ ] Yes [x] No ``` ## Pull Request Type What kind of change does this Pull Request introduce? <!-- Please check the one that applies to this PR using "x". --> ``` [ ] Bugfix [ ] Feature [ ] Code style update (formatting, local variables) [ ] Refactoring (no functional changes, no api changes) [ ] Documentation content changes [x] Other... Please describe: ``` --------- Co-authored-by: Tycen Hopkins <[email protected]>
1 parent 312e261 commit 723d6e9

File tree

20 files changed

+380
-96
lines changed

20 files changed

+380
-96
lines changed

.devcontainer/funcs.sh

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,8 @@
22

33
DEV_ENV_FILE="$HOME/.dev-environment"
44

5-
function saveenv() {
6-
declare -p | grep "declare \(--\|-x\)" | grep -v "^declare \(--\|-x\) \(PS[0-9]\|BASH_.*\|PATH\|PWD\|LS_COLORS\)=" > "$DEV_ENV_FILE"
7-
}
5+
alias saveenv='declare -p | grep "declare \(--\|-x\)" | grep -v "^declare \(--\|-x\) \(PS[0-9]\|_.*\|SDKMAN_.*\|sdkman_.*\|IFS\|VSCODE_.*\|HIST.*\|GITHUB_.*\|BASH_.*\|COMP_WORDBREAKS\|PATH\|OLDPWD\|PWD\|LS_COLORS\)=" > "$DEV_ENV_FILE"'
86

9-
function clearenv() {
10-
rm -f "$DEV_ENV_FILE"
11-
}
7+
alias loadenv='source "$DEV_ENV_FILE"'
128

9+
alias clearenv='rm -f "$DEV_ENV_FILE"'

.devcontainer/postCreateCommand.sh

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
#!/usr/bin/env bash
22

33
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
4-
source "$DIR/funcs.sh"
54

65
azd config set alpha.deployment.stacks on
76

8-
grep saveenv "$HOME/.bashrc" > /dev/null 2>&1
7+
grep JAVA_AI_FUNC "$HOME/.bashrc" > /dev/null 2>&1
98
if [[ $? -ne 0 ]]; then
109

1110
cat <<EOT >> "$HOME/.bashrc"
11+
JAVA_AI_FUNC="$DIR"
12+
[ -f "\$JAVA_AI_FUNC/funcs.sh" ] && \. "\$JAVA_AI_FUNC/funcs.sh"
1213
13-
DEV_ENV_FILE="\$HOME/.dev-environment"
14-
15-
# auto load
16-
if [[ -f "\$DEV_ENV_FILE" ]]; then
17-
source "\$DEV_ENV_FILE"
18-
fi
14+
loadenv
1915
2016
EOT
2117

22-
declare -f saveenv clearenv >> "$HOME/.bashrc"
23-
2418
fi

.devcontainer/saveenv.sh

Lines changed: 0 additions & 4 deletions
This file was deleted.

docs/02_lab_launch/0201.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,16 @@ parent: 'Lab 2: Deploy applications to Azure Container Apps'
77

88
# Collect user information
99

10-
First, you’ll need to sign your lab environment in to Azure and configure it to access the lab subscription. Then you’ll store your user info for use in subsequent steps.
10+
Before performing any additional actions, you'll need to store your user info as an environment variable that you can use in subsequent steps.
11+
12+
{: .note }
13+
We already collected your subscription information as part of the [preparing your subscription]({% link install.md %}#preparing-your-subscription) instructions. Make sure you've completed this process and and any other [installation steps]({% link install.md %}) are complete before proceeding.
1114

1215
## Step-by-step guidance
1316

1417
{: .note }
1518
We'll be using Bash commands to complete this lab. You can use any compatible command-line environment, such as the Windows Subsystem for Linux, Git Bash, or the Visual Studio Code Bash terminal. To avoid potential errors, **do not** run these commands in a PowerShell session.
1619

17-
1. In your lab environment, open a command-line environment and sign in to your Azure subscription with the following command:
18-
19-
```bash
20-
az login
21-
```
22-
23-
{: .note }
24-
> If you’re running this lab in GitHub Codespaces, use az login --use-device-code.
25-
26-
When you execute the command, it automatically opens a web browser window and requires that you authenticate. When prompted, sign in with the user account (with the Owner role) in the Azure subscription that you have for this lab and then close the browser window.
27-
28-
1. Make sure that you’re signed in to the lab subscription:
29-
30-
```bash
31-
az account list -o table
32-
```
33-
34-
If you don't see the correct lab account listed as your default one, use the following command to adjust your Azure CLI session to use the correct subscription (replace \<*subscription-id*\> with the lab subscription’s ID):
35-
36-
```bash
37-
az account set --subscription <subscription-id>
38-
```
39-
4020
1. Collect your user info, and then store it for future use.
4121
- Store your username in an environment variable:
4222

docs/02_lab_launch/0209.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ The following image should reflect your application architecture after a success
1414
![lab 2 overview](../../images/acalab2.png)
1515

1616
{: .important }
17-
> The work you did in this lab is fundamental to the next several labs you’ll be working through, so please do not delete any of the Azure resources you've created here.
17+
> The work you did in this lab is fundamental to both this lab and the next several labs you’ll be working through, so please do not delete any of the Azure resources you've created here.
1818
>
19-
>In addition to those resources, you also defined some environment variables as part of this lab, and many of these are also required in subsequent labs. To make sure you don't lose these variables after closing your current bash session, you'll want to save them.
19+
> As we mentioned in the [Install instructions]({% link install.md %}#preparing-your-subscription), you can use both the `saveenv` and `loadenv` commands to manually save and load your environment variables at any time.
2020
>
21-
> Before you move forward, in your open command-line window, go to the `spring-petclinic-microservices` directory and run the command `source ../.devcontainer/saveenv.sh`. This will save the environment variables to the file `~/.dev-environment`, and any new bash sessions you start will automatically load the required variables.
22-
>
23-
> You can also manually load the saved variables with the command `source ~/.dev-environment`.
21+
>You've done a lot in this lab, so now is a good time to run `saveenv` to make sure your current environment variables will be there if you have to start a new bash session.

docs/03_lab_openai/0301.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ The following step-by-step guidance will show you how to create an Azure OpenAI
1818

1919
1. To create an Azure OpenAI account, run the following commands. Note that the account name you use here must be globally unique, so adjust it accordingly if the randomly generated name is already in use.
2020

21+
Azure OpenAI Service is not supported in all regions, you may refer to [Azure OpenAI global standard model availability](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#models-by-deployment-type) for more details.
22+
23+
You may use these regions for your lab: **australiaeast**, **brazilsouth**, **southindia**, **japaneast**, **swedencentral**, **eastus**, **eastus2** and **westus**.
24+
2125
```bash
26+
AI_LOCATION=<ai-location>
27+
2228
OPEN_AI_SERVICE_NAME=open-ai-account-$UNIQUEID
2329
az cognitiveservices account create \
2430
--resource-group $RESOURCE_GROUP \
2531
--name $OPEN_AI_SERVICE_NAME \
26-
--location $LOCATION \
32+
--location $AI_LOCATION \
2733
--kind OpenAI \
2834
--sku s0 \
2935
--custom-domain $OPEN_AI_SERVICE_NAME

docs/04_lab_monitor/0403.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ For additional information on how this works, review:
2929
1. Your first step is to create an Application Insights resource. Execute this statement in your command-line environment:
3030

3131
```bash
32-
az extension add -n application-insights --upgrade --yes
33-
3432
APP_INSIGHTS_NAME=app-insights-$APPNAME-$UNIQUEID
3533
az monitor app-insights component create \
3634
--resource-group $RESOURCE_GROUP \

docs/04_lab_monitor/0405.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,20 @@ If you’d like to learn more about how Azure Managed Grafana helps visualize ex
1818

1919
## Step-by-step guidance
2020

21-
1. Provision Azure Manage Grafana. In your command-line environment, create an Azure Managed Grafana instance:
21+
1. Provision Azure Managed Grafana. In your command-line environment, create an Azure Managed Grafana instance:
22+
23+
Azure Managed Grafana is not supported in all regions. You can refer to the [Azure OpenAI global standard model availability](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions#models-by-deployment-type) documentation for more details if you'd like.
24+
25+
However, for the purposes of this lab, we recommend using one of the following regions when creating an Azure Managed Grafana instance: **australiaeast**, **brazilsouth**, **centralindia**, **japaneast**, **swedencentral**, **eastus**, **eastus2** and **westus**.
2226

2327
```bash
24-
az extension add --name amg --upgrade -y
28+
GRAFANA_LOCATION=<grafana-location>
2529

2630
GRAFANA_NAME=amg-$UNIQUEID
2731
az deployment group create \
2832
--resource-group $RESOURCE_GROUP \
2933
--template-file ../infra/bicep/modules/grafana/grafana-dashboard.bicep \
30-
--parameters grafanaName=$GRAFANA_NAME
34+
--parameters grafanaName=$GRAFANA_NAME location=$GRAFANA_LOCATION
3135
```
3236

3337
1. Grant yourself the Grafana Admin role. You’ll need this role to manage your Grafana dashboard. Use the following Azure CLI command to add the role assignment:

docs/05_lab_secrets/0503.md

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ For more information about connecting resources to Azure Service Connector, refe
1313

1414
## Step-by-step guidance
1515

16-
1. Add the serviceconnector-passwordless extension to your Azure CLI instance:
17-
18-
```bash
19-
az extension add --name serviceconnector-passwordless --upgrade -y
20-
```
21-
2216
1. Get the account and resource information to create a Service Connector, and store them as environment variables for later use:
2317

2418
```bash

docs/06_lab_automation/0603.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,3 @@ Check the failures, fix the problems and rerun `azd up` to continue the automati
7676

7777
`az account set -s <subscription>`
7878

79-
- Check the az extension
80-
81-
Run command `az extension list -o table`, you should see both extension **containerapps** and **serviceconnector-passwordless** installed. If not, install with
82-
83-
`az extension add -n <name>`

index.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,19 @@ To run this lab, you’ll need:
3737
2. This lab also uses [Azure Database for MySQL - Flexible Server](https://learn.microsoft.com/azure/mysql/flexible-server/overview). Before deploying or selecting a region, be sure to [verify the service is available](https://learn.microsoft.com/en-us/azure/mysql/flexible-server/overview#azure-regions) in that region.
3838

3939
{: .note }
40-
> At the time of publishing (January 2025), we recommend using any of the following regions to help ensure that required features are available: **West US**, **West US 2**, **East US 2**, **North Central US**, **Sweden Central**.
40+
> - At the time of publishing (January 2025), we recommend using any of the following regions to help ensure that required features are available: **East Asia**, **Australia East**, **Brazil South**, **South India**, **Japan East**, **Sweden Central**, **East US 2** and **West US**.
41+
> - If you encounter SKU or quota issues when attempting to create resources during any of these labs, feel free to create the resource in another one of these recommended regions.
4142
4243
### Installation
4344

4445
Before running this lab, be sure that all the required tooling is available. We’ve provided three options:
4546

46-
* [Use GitHub Codespaces (preferred)]({% link install.md %}#using-a-github-codespace), which will create a cloud-based development environment with the required tools installed and configured.
47+
* [Use GitHub Codespaces (preferred)]({% link install.md %}#use-github-codespaces-strongly-recommended), which will create a cloud-based development environment with the required tools installed and configured.
4748
* [Use Visual Studio Code with remote containers option]({% link install.md %}#using-visual-studio-code-with-remote-containers), which will create a Docker container on your local machine with the required tools preconfigured.
48-
* [Install all the tools on your local machine]({% link install.md %}#install-all-the-tools-on-your-local-machine).
49+
* [Install all the tools on your local machine]({% link install.md %}#install-all-the-tools-on-your-local-machine-not-recommended).
4950

50-
We’ve tested this lab using GitHub Codespaces, which is the preferred option for running it.
51+
We’ve tested this lab using GitHub Codespaces, which is the recommended option for running it.
52+
53+
After the tooling is set up, you'll need to perform some steps to [prepare your subscription]({% link install.md %}#preparing-your-subscription) before continuing with the labs.
5154

5255
You can find the full installation guidance and the options for running this lab in the [Installation]({% link install.md %}) instructions.

infra/bicep/main.bicep

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@ param environmentName string
77

88
@minLength(2)
99
@description('Primary location for all resources.')
10+
@allowed([
11+
'australiaeast'
12+
'brazilsouth'
13+
'eastus2'
14+
'japaneast'
15+
'southindia'
16+
'swedencentral'
17+
'westus'
18+
])
1019
param location string
1120

1221
@description('Name of the the resource group. Default: rg-{environmentName}')

infra/bicep/modules/grafana/grafana-dashboard.bicep

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ targetScope = 'resourceGroup'
33
@description('Required. Name of your Azure Managed Grafana resource.')
44
param grafanaName string
55

6+
@description('Required. Location of your Azure Managed Grafana resource.')
7+
param location string
8+
69
@description('Optional. Tags of the resource.')
710
param tags object = {}
811

@@ -11,6 +14,7 @@ module azureManagedGrafana 'azure-managed-grafana.bicep' = {
1114
scope: resourceGroup()
1215
params: {
1316
grafanaName: grafanaName
17+
location: location
1418
tags: tags
1519
}
1620
}

0 commit comments

Comments
 (0)