Skip to content

Harjit managed app #241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
98fc3b8
refactor of bicep variable names to be more generic and pytest cleanup
jgbradley1 Jan 2, 2025
2b41976
add RBAC reader role assignment to cosmosdb bicep deployment
jgbradley1 Jan 2, 2025
699bfa5
update dependabot settings
jgbradley1 Jan 2, 2025
ff5714a
update code references to new locations in graphrag library
jgbradley1 Jan 3, 2025
0252646
refactor variable names to be more generic and add integration tests
jgbradley1 Jan 3, 2025
fbbad71
add new pytests
jgbradley1 Jan 3, 2025
2f744c1
ruff format updates
jgbradley1 Jan 3, 2025
4e1b1ba
revert bicep api version changes to a working condition
jgbradley1 Jan 3, 2025
44d7859
fix bad import
jgbradley1 Jan 3, 2025
97d8b52
temporary move of import statement
jgbradley1 Jan 4, 2025
3c96059
update synthetic index dataset
jgbradley1 Jan 4, 2025
96dcd95
refactor bicep to be cleaner and remove ssh public key generation for…
jgbradley1 Jan 4, 2025
8d448f8
update common bicep variable name
jgbradley1 Jan 4, 2025
863bff3
add aoai to bicep deployment
jgbradley1 Jan 6, 2025
f068846
cleanup bicep variable names
jgbradley1 Jan 6, 2025
743d587
cleanup optional parameters and define default values in helm chart
jgbradley1 Jan 6, 2025
b6153f3
auto-format bicep code
jgbradley1 Jan 7, 2025
5f78d37
auto format code
jgbradley1 Jan 7, 2025
bc24bfa
fix aoai deployment issue
jgbradley1 Jan 7, 2025
ca0c489
working version of a managed app
jgbradley1 Jan 8, 2025
25be69f
Merge branch 'main' into joshbradley/convert-to-managed-app
jgbradley1 Jan 30, 2025
24df161
fix changes after merge with main
jgbradley1 Jan 31, 2025
871b192
fix synthetic dataset after merge with main
jgbradley1 Jan 31, 2025
82871df
updated for build
harjitdotsingh Feb 5, 2025
964b536
updated for build
harjitdotsingh Feb 11, 2025
6364389
ManagedAPP
harjitdotsingh Feb 11, 2025
b687cc0
Updated URL
harjitdotsingh Feb 11, 2025
a4dede0
updated README
harjitdotsingh Feb 11, 2025
9656f87
updated Config
harjitdotsingh Feb 12, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions backend/tests/integration/test_api_index_configuration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""
Integration tests for the /index/config API endpoints.
"""

from unittest.mock import AsyncMock, patch

import pytest_asyncio


@pytest_asyncio.fixture
def mock_generate_indexing_prompts():
with patch(
"graphrag.api.generate_indexing_prompts", new_callable=AsyncMock
) as mock:
mock.return_value = (
"synthetic-prompt1",
"synthetic-prompt2",
"synthetic-prompt3",
)
yield mock


def test_generate_prompts(
blob_with_data_container_name, mock_generate_indexing_prompts, client
):
"""Test generating prompts."""
response = client.get(
"/index/config/prompts",
params={"storage_name": blob_with_data_container_name},
)
assert response.status_code == 200
53 changes: 53 additions & 0 deletions infra/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Managed App Instructions

This guide is a temporary document that walks through the process to convert the graphrag solution accelerator to a managed app.

### Prerequisites
### 1. create a ACR and push the code to a docker image.
### 2. This managed app uses storage account to deploy, so please copy the storage account name and the SAS key.
### 3. When publishing the managed app , please turn on anon access to the Blob where the package can be accessed.

### Steps to build Managed App

### 1. Auto format the bicep code

As a precaution, start by auto-formating and linting the bicep code to detect any mistakes early-on.

```bash
cd <repo_root_directory>/infra
find . -type f -name "*.bicep" -exec az bicep format --file {} \;
find . -type f -name "*.bicep" -exec az bicep lint --file {} \;
```

### 2. Convert bicep -> ARM
```bash
az bicep build --file main.bicep --outfile managed-app/mainTemplate.json
```

### 3. Create & test the Azure portal interface

Use the [Azure Portal Sandbox](https://portal.azure.com/#blade/Microsoft_Azure_CreateUIDef/SandboxBlade) to test and make any UI changes that are defined in [createUiDefinition.json](createUiDefinition.json). To make additional changes to the Azure portal experience, start by reading some [documentation](https://learn.microsoft.com/en-us/azure/azure-resource-manager/managed-applications/create-uidefinition-overview) and copying the contents of `createUiDefinition.json` into the sandbox environment.

### 4. Package up the managed app code

The name of the final two files (`mainTemplate.json` and `createUiDefinition.json`) cannot be changed. The file names are also case-sensitive and cannot be changed at this time. Managed apps require these files to be packaged up into a zip file (where the json files must be at the root directory).

```bash
cd <repo_root_directory>/infra/managed-app
tar -a -c -f managed-app.zip createUiDefinition.json mainTemplate.json openapi.json artifacts
```

This zip file can then be uploaded to an Azure Storage location when setting up a [Service Catalog Managed Application Definition](https://ms.portal.azure.com/#view/Microsoft_Azure_Marketplace/GalleryItemDetailsBladeNopdl/id/Microsoft.ApplianceDefinition/selectionMode~/false/resourceGroupId//resourceGroupLocation//dontDiscardJourney~/false/selectedMenuId/home/launchingContext~/%7B%22galleryItemId%22%3A%22Microsoft.ApplianceDefinition%22%2C%22source%22%3A%5B%22GalleryFeaturedMenuItemPart%22%2C%22VirtualizedTileDetails%22%5D%2C%22menuItemId%22%3A%22home%22%2C%22subMenuItemId%22%3A%22Search%20results%22%2C%22telemetryId%22%3A%2220409084-39a1-4800-bbce-d0b26a6f46a4%22%7D/searchTelemetryId/d7d20e05-ca16-47f7-bed5-9c7b8d2fa641).

### 5. Create the Service Catalog Managed App Definition

In the Azure Portal, go to Marketplace and create a `Service Catalog Managed App Definition`. You must provide a uri link to the uploaded `managed-app.zip` file as part of the creation process.

### 6. Deploy the managed app


You can deploy from the portal using the following steps In the Azure Portal, find and click on the managed app definition resource that was created in the previous step. A button option to `Deploy from definition` will be available. Click on it and proceed through the setup steps (defined by the `createUiDefinitions.json` file) that a consumer would experience when installing the managed app.


or you can deploy to azure [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fgraphrag-accelerator%2Frefs%2Fheads%2Fharjit-managed-app%2Finfra%2FmainTemplate.json)

2 changes: 1 addition & 1 deletion infra/core/aks/aks.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ resource aks 'Microsoft.ContainerService/managedClusters@2024-09-02-preview' = {
}
properties: {
enableRBAC: true
disableLocalAccounts: true
disableLocalAccounts: false
dnsPrefix: !empty(dnsPrefix) ? dnsPrefix : toLower(clusterName)
aadProfile: {
managed: true
Expand Down
80 changes: 80 additions & 0 deletions infra/core/aoai/aoai.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
@description('Name of the Azure OpenAI instance')
param openAiName string = 'openai${uniqueString(resourceGroup().id)}'

@description('Location for the Azure OpenAI instance')
param location string = resourceGroup().location

@description('LLM model name')
param llmModelName string = 'gpt-4o'

@description('LLM Model API version')
param llmModelVersion string

@description('Embedding model name')
param embeddingModelName string = 'text-embedding-ada-002'

@description('Embedding Model API version')
param embeddingModelVersion string

@description('TPM quota for llm model deployment (x1000)')
param llmTpmQuota int = 1

@description('TPM quota for embedding model deployment (x1000)')
param embeddingTpmQuota int = 1

resource aoai 'Microsoft.CognitiveServices/accounts@2024-10-01' = {
name: openAiName
location: location
sku: {
name: 'S0'
}
kind: 'OpenAI'
properties: {
publicNetworkAccess: 'Enabled'
disableLocalAuth: true
}
}

resource llmDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-10-01' = {
parent: aoai
name: llmModelName
sku: {
name: 'GlobalStandard'
capacity: llmTpmQuota
}
properties: {
model: {
format: 'OpenAI'
name: llmModelName
version: llmModelVersion
}
currentCapacity: llmTpmQuota
}
}

resource embeddingDeployment 'Microsoft.CognitiveServices/accounts/deployments@2024-10-01' = {
parent: aoai
name: embeddingModelName
// NOTE: simultaneous model deployments are not supported at this time. As a workaround, use dependsOn to force the models to be deployed in a sequential manner.
dependsOn: [llmDeployment]
sku: {
name: 'Standard'
capacity: embeddingTpmQuota
}
properties: {
model: {
format: 'OpenAI'
name: embeddingModelName
version: embeddingModelVersion
}
currentCapacity: embeddingTpmQuota
}
}

output openAiEndpoint string = aoai.properties.endpoint
output llmModel string = llmDeployment.properties.model.name
output llmModelDeploymentName string = llmDeployment.name
output llmModelApiVersion string = llmDeployment.apiVersion
output textEmbeddingModel string = embeddingDeployment.properties.model.name
output textEmbeddingModelDeploymentName string = embeddingDeployment.name
output textEmbeddingModelApiVersion string = embeddingDeployment.apiVersion
5 changes: 4 additions & 1 deletion infra/core/apim/apim.graphrag-servicedef.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ param backendUrl string
param name string
param apimname string




resource api 'Microsoft.ApiManagement/service/apis@2023-09-01-preview' = {
name: '${apimname}/${name}'
properties: {
Expand All @@ -24,7 +27,7 @@ resource api 'Microsoft.ApiManagement/service/apis@2023-09-01-preview' = {
}
isCurrent: true
format: 'openapi+json'
value: string(loadJsonContent('graphrag-openapi.json')) // local file will be dynamically created by deployment script
value: string(loadJsonContent('../../managed-app/openapi.json')) // local file will be dynamically created by deployment script
}
resource apiPolicy 'policies@2022-08-01' = {
name: 'policy'
Expand Down
Loading
Loading