diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/challenge-01.md b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/challenge-01.md index b775de077..ad37a4839 100644 --- a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/challenge-01.md +++ b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/challenge-01.md @@ -53,25 +53,78 @@ The remaining challenges use this pre-provisioned environment and a repository h Complete this setup with the credentials provided in your Hackbox. Use the assigned lab account rather than a personal or work account so that you have access to the correct Azure subscription, resource group, GitHub organization, and repository. +> [!TIP] +> Use an InPrivate or Incognito browser session for this lab to avoid mixing your personal or other work accounts when signing in to Azure and GitHub. + ## ✅ Tasks ### 1. Sign in to Azure -Open the [Azure portal](https://portal.azure.com) and sign in with the credentials provided in your Hackbox, choosing **Use another account** when prompted. +Open the [Azure portal](https://portal.azure.com) and sign in with the credentials provided in your Hackbox (see the **Credentials** section at the top of this web page). If you are prompted to pick an account, choose **Use another account**. + +Pick account for login + +Enter the provided **Entra ID Username** and **Entra ID TAP** from the **Credentials** section at the top of this page. + +Sign in + +In the Azure portal, select **Resource groups** from the start page. + +Sign in -In the Azure portal, select **Resource groups**, open the resource group assigned to you, and confirm that its resources have been deployed successfully. Verify that you can see the Foundry project, the Cosmos DB account, the Storage account, and the API Management instance described in [Context and Background](#-context-and-background). + +Open the resource group assigned to you and confirm that its resources have been deployed successfully. + +Azure resources + +Verify that you can see the Foundry project, the Cosmos DB account, the Storage account, and the API Management instance described in [Context and Background](#-context-and-background). + +> [!NOTE] +> The Location column values might differ from the screenshot since the resources are provisioned across multiple regions. ### 2. Sign in to GitHub -Open [GitHub](https://github.com) and sign in with the credentials provided in your Hackbox, choosing **Use another account** and then **Sign in with your identity provider**. +Open [GitHub login page](https://github.com/login) and sign in with the **Github SSO Login User** username provided in your Hackbox and select **Sign in with your identity provider**. + +GitHub login + +Select **Continue** and accept the consent prompt. + +Open the GitHub organization assigned to your lab account by first selecting the avatar in the top right corner and then **Organizations** -Open the organization associated with your lab account and select the `MicroHack` repository. Confirm that you can see the repository files and folders, including `03-Azure/01-04-AI/08_Predictive_Maintenance`. +GitHub organization + +Select the assigned organization, then open the pinned microhack repository. + +GitHub organization + +Microhack repository + +You then need to fork the repository before you can create a Codespace. To fork the repository, click the Fork button in the top-right corner of the repository page and follow the prompts: + +Create fork + +Select the organization as owner and use a unique name for the repository name to avoid conflicts with other forks. For example, you can append your lab username to the repository name (e.g., `microhack-labuser-0001`): + +Fork name + +Finally, you should see your forked repository with the unique name you provided and all files and folders from the original repository: + +Forked repository ### 3. Create the development environment -From the repository page, select **Code**, open the **Codespaces** tab, then use the `...` menu to choose **New with options**. For **Dev container configuration**, select **Azure / AI / Predictive Maintenance**, then select **Create codespace**. +From the repository page, select **Code**, then open the **Codespaces** tab. Select the ... menu and choose **New with options**. + +New Codespace + +For Dev container configuration, select **Azure / AI / Predictive Maintenance**, then select **Create codespace**: -GitHub opens the Codespace in a new browser tab. Wait for the container setup to finish, then confirm that the repository files are visible in the Explorer and that the integrated terminal opens without errors. +Select Dev Container + +Wait for the container setup to finish, then select the **Trust folders & Continue** button and confirm that the repository files are visible in the Explorer and that the integrated terminal opens without errors. + +Codespace welcome Open a terminal in the Codespace and verify that the required tools are installed: @@ -80,14 +133,12 @@ az --version dotnet --version ``` -Install the pinned Python dependencies and activate the environment: +The pinned Python dependencies were installed automatically when the Codespace was created. Verify that the virtual environment is active: ```bash -uv sync --frozen -source .venv/bin/activate +which python # should point to .../.venv/bin/python ``` - -Sign in to Azure from the Codespace terminal with the assigned lab account: +Sign in to Azure from the Codespace terminal follow the link shown to authenticate with a web browser and the device code using the assigned lab account: ```bash az login --use-device-code @@ -95,10 +146,10 @@ az login --use-device-code ### 4. Retrieve environment configuration -From the repository root, run the setup script with the resource group name provided in your Hackbox: +From the repository root, run the setup script with the resource group name provided in your Hackbox under **Resource Group Name**: ```bash -bash labautomation/get-keys.sh --resource-group "" +labautomation/get-keys.sh --resource-group "" ``` The script locates your deployed lab resources and creates a local `.env` file. It retrieves the Foundry project endpoint, Cosmos DB connection details, Storage account connection string, and Azure AI Search key and endpoint required by the remaining challenges. The file is excluded from Git and its secret values are not displayed. diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-portal-resources.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-portal-resources.png index 6b5e1920e..85ecd9cdd 100644 Binary files a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-portal-resources.png and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-portal-resources.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-resources.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-resources.png index c83f01f8f..e12a3acc9 100644 Binary files a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-resources.png and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-azure-resources.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-codespace-welcome.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-codespace-welcome.png new file mode 100644 index 000000000..4f164d9f3 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-codespace-welcome.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-fork-name.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-fork-name.png new file mode 100644 index 000000000..499c18bcd Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-fork-name.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-fork-repo.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-fork-repo.png new file mode 100644 index 000000000..b05ca1837 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-fork-repo.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-forked-repository.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-forked-repository.png new file mode 100644 index 000000000..215586117 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-forked-repository.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-login.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-login.png new file mode 100644 index 000000000..71e2f977e Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-login.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-organization.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-organization.png new file mode 100644 index 000000000..05fcd6555 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-organization.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-pinned-repository.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-pinned-repository.png new file mode 100644 index 000000000..6f3edb7d2 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-github-pinned-repository.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-new-codespace-with-options.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-new-codespace-with-options.png new file mode 100644 index 000000000..43e0c2eec Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-new-codespace-with-options.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-pick-account.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-pick-account.png new file mode 100644 index 000000000..5a5a5d966 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-pick-account.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-resource-groups-portal.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-resource-groups-portal.png new file mode 100644 index 000000000..d1580f180 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-resource-groups-portal.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-select-devcontainer.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-select-devcontainer.png new file mode 100644 index 000000000..086b0f7f7 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-select-devcontainer.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-select-github-organization.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-select-github-organization.png new file mode 100644 index 000000000..ea8306b80 Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-select-github-organization.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-sign-in.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-sign-in.png new file mode 100644 index 000000000..09e1afabf Binary files /dev/null and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-01-sign-in.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-azure-resources.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-azure-resources.png index 8d6cfa6e8..6efad7cd0 100644 Binary files a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-azure-resources.png and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-azure-resources.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-select-python-environment.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-select-python-environment.png index fd8a6aa45..5eb487a48 100644 Binary files a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-select-python-environment.png and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-02-select-python-environment.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-04-azure-resources.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-04-azure-resources.png index f285f2dee..d162dcf31 100644 Binary files a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-04-azure-resources.png and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-04-azure-resources.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-05-azure-resources.png b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-05-azure-resources.png index 3c50d29e0..cf19b8378 100644 Binary files a/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-05-azure-resources.png and b/03-Azure/01-04-AI/08_Predictive_Maintenance/challenges/images/challenge-05-azure-resources.png differ diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/get-keys.sh b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/get-keys.sh index f285f2e5d..2d29394cd 100755 --- a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/get-keys.sh +++ b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/get-keys.sh @@ -181,6 +181,8 @@ EMBEDDING_MODEL_DEPLOYMENT_NAME="text-embedding-3-large" AZURE_OPENAI_ENDPOINT="$azureOpenAIEndpoint" AZURE_OPENAI_KEY="$foundryKey" AZURE_OPENAI_DEPLOYMENT_NAME="gpt-5.4" +# Read by agent_framework's OpenAIChatClient (Challenge 2 Python agents) +AZURE_OPENAI_CHAT_MODEL="gpt-5.4-mini" # Azure Cosmos DB (SQL API) COSMOS_ACCOUNT_NAME="$cosmosAccountName" diff --git a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep index 81f5e6d78..92e765ef4 100644 --- a/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep +++ b/03-Azure/01-04-AI/08_Predictive_Maintenance/labautomation/main.bicep @@ -34,6 +34,7 @@ var searchServiceContributorRoleId = subscriptionResourceId('Microsoft.Authoriza var searchIndexDataReaderRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '1407120a-92aa-4202-b7e9-c0e197c71c8f') var monitoringReaderRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '43d0d8ad-25c7-4714-9337-8ba259a9fe05') var foundryUserRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '53ca6127-db72-4b80-b1b0-d745d6d5456d') +var openAiContributorRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'a001fd3d-188f-4b5d-821b-7da978bf7442') var storageBlobDataContributorRoleId = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', 'ba92f5b4-2d11-453d-a403-e96b0029c9fe') var cosmosDbDataContributorRoleId = '00000000-0000-0000-0000-000000000002' @@ -440,6 +441,28 @@ resource participantFoundryUser 'Microsoft.Authorization/roleAssignments@2022-04 } } +// Account-scope access: the Responses API (/openai/v1/responses) is a data action +// on the Foundry/AI Services account, not on the project. +resource participantFoundryUserOnAccount 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: aiFoundry + name: guid(aiFoundry.id, userObjectId, foundryUserRoleId) + properties: { + roleDefinitionId: foundryUserRoleId + principalId: userObjectId + principalType: 'User' + } +} + +resource participantOpenAiContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = { + scope: aiFoundry + name: guid(aiFoundry.id, userObjectId, openAiContributorRoleId) + properties: { + roleDefinitionId: openAiContributorRoleId + principalId: userObjectId + principalType: 'User' + } +} + resource participantCosmosDataContributor 'Microsoft.DocumentDB/databaseAccounts/sqlRoleAssignments@2025-05-01-preview' = { parent: cosmosDbAccount name: guid(cosmosDbAccount.id, userObjectId, cosmosDbDataContributorRoleId)