Skip to content
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

Azdevify chat-with-your-data-solution-accelerator. #2

Merged
merged 45 commits into from
Feb 6, 2024
Merged

Azdevify chat-with-your-data-solution-accelerator. #2

merged 45 commits into from
Feb 6, 2024

Conversation

zedy-wj
Copy link
Collaborator

@zedy-wj zedy-wj commented Nov 5, 2023

This pr is all changes to convert chat-with-your-data-solution-accelerator application into an Azd template.

You can currently deploy this application using azd by following the steps below:

  1. Execute the command: azd init -t zedy-wj/chat-with-your-data-solution-accelerator-azdevify -b azdevify
  2. Execute the command: azd up
  3. Wait a moment for the resource deployment to complete, click the Website endpoint and you will see:
image

@jongio - for notification.

@zedy-wj zedy-wj marked this pull request as ready for review November 5, 2023 06:12
@v-xuto v-xuto mentioned this pull request Nov 5, 2023
azure.yaml Outdated Show resolved Hide resolved
azure.yaml Outdated Show resolved Hide resolved
azure.yaml Outdated Show resolved Hide resolved
infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/websiteadmin.bicep Outdated Show resolved Hide resolved
@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Nov 7, 2023

@jongio - Updated according to your comments, please re-review it, thanks!

infra/app/adminweb.bicep Outdated Show resolved Hide resolved
infra/app/adminweb.bicep Outdated Show resolved Hide resolved
infra/app/function.bicep Show resolved Hide resolved
infra/app/resources.bicep Outdated Show resolved Hide resolved
infra/app/storage.bicep Outdated Show resolved Hide resolved
infra/main.bicep Outdated Show resolved Hide resolved
infra/main.bicep Outdated Show resolved Hide resolved
infra/main.bicep Show resolved Hide resolved
infra/main.bicep Outdated Show resolved Hide resolved
infra/app/storage.bicep Outdated Show resolved Hide resolved
@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Nov 10, 2023

@jongio - Updated according to your comments, please re-review this pr. Thanks!

@jongio
Copy link
Owner

jongio commented Nov 13, 2023

  1. Execute the command: azd init -t https://github.com/zedy-wj/chat-with-your-data-solution-accelerator-azdevify.git -b azdevify

You don't need the full URL, azd init -t zedy-wj/chat-with-your-data-solution-accelerator-azdevify -b azdevify works

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/web.bicep Outdated Show resolved Hide resolved
infra/core/ai/cognitiveservices.bicep Show resolved Hide resolved
infra/main.bicep Show resolved Hide resolved
infra/main.bicep Show resolved Hide resolved
@jongio
Copy link
Owner

jongio commented Nov 17, 2023

  1. Execute the command: azd init -t zedy-wj/chat-with-your-data-solution-accelerator-azdevify.git -b azdevify

FYI - You don't need ".git" in the name

Comment on lines 28 to 29
AZURE_OPENAI_KEY: listKeys('Microsoft.CognitiveServices/accounts/${azureOpenAIName}', '2023-05-01').key1
AZURE_SEARCH_KEY: listAdminKeys('Microsoft.Search/searchServices/${azureCognitiveSearchName}', '2021-04-01-preview').primaryKey
Copy link
Owner

@jongio jongio Nov 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We really shouldn't be using KEYS and instead use RBAC like we do in all the other samples.

Example:

You assign the right roles to the service principal of the azure resources that need to access those services and don't use KEYs in app settings at all.

  1. Add a parameter to the main.bicep that allows the user to either use RBAC or KEYS. Call it AUTH_TYPE and default it to rbac. And set @Allowed to 'rbac' or 'keys'
  2. If the auth type is rbac, then use roles. If auth type is keys, then use keys.

Use this as example for how to use RBAC https://github.com/Azure-Samples/azure-search-openai-demo/blob/main/infra/main.bicep#L353

For 'keys'
You can look up the keys with this listKeys method. Example for storage.

listKeys(resourceId(subscription().subscriptionId, rgName, 'Microsoft.Storage/storageAccounts', storageAccountName), '2021-09-01').keys[0].value

It's like what you had before, but you also include the subscriptionId and RgName

infra/app/function.bicep Show resolved Hide resolved
zedy added 4 commits November 22, 2023 14:31
add keyvault option to get secret keys

remove invalid changes

add param useKeyVault
@jongio
Copy link
Owner

jongio commented Nov 30, 2023

@zedy-wj Please LMK when ready for re-review. Thanks

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Dec 1, 2023

@jongio If using KeyVault or KEYS, the code is now ready for re-review. If want to use RBAC or KEYS, there are currently some difficulties in obtaining the search key. For details, please refer to the comment here.

Which method do you prefer, RBAC or KeyVault?

@jongio
Copy link
Owner

jongio commented Dec 5, 2023

@zedy-wj - Please move forward to using the search SDK instead of REST calls.

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Jan 11, 2024

@jongio - We have updated all the code based on your comments, and updated infra/core to be consistent with azure-dev, please re-review it, thanks!

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@@ -0,0 +1,31 @@
{
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the back and forth on this. Let's do this:

Default to using rbac.

If AUTH_TYPE is rbac, then assume the developer wants to also use key vault. Put the keys in keyvault and then read them from keyvault.

If the user sets AUTH_TYPE to keys, then read the keys from the environment and set the keys using listKeys function.

I think that will be cleaner.

infra/app/function.bicep Outdated Show resolved Hide resolved
infra/app/storage.bicep Outdated Show resolved Hide resolved
infra/app/storekeys.bicep Outdated Show resolved Hide resolved
infra/main.bicep Outdated Show resolved Hide resolved
@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Jan 12, 2024

@jongio - Updated according to your comments. For some things that haven’t been changed yet, please see my reply to your comments above, thanks!

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Jan 17, 2024

@jongio - The relevant changes in output have been updated. We are still a little confused about AUTH_TYPE. For details, please refer to my comments here.
image

@jongio
Copy link
Owner

jongio commented Jan 22, 2024

@zedy-wj - Are you ready for me to rereview this?

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Jan 23, 2024

@jongio - Yes, it's ready for re-review.

README.md Outdated Show resolved Hide resolved
app.py Outdated Show resolved Hide resolved
app.py Outdated Show resolved Hide resolved
backend/utilities/helpers/EnvHelper.py Outdated Show resolved Hide resolved
backend/utilities/helpers/EnvHelper.py Outdated Show resolved Hide resolved
infra/main.bicepparam Outdated Show resolved Hide resolved
app.py Outdated Show resolved Hide resolved
@jongio
Copy link
Owner

jongio commented Jan 26, 2024

@zedy-wj @v-xuto There have been a significant amount of changes to the main repo: https://github.com/Azure-Samples/chat-with-your-data-solution-accelerator, since we started this PR. They already implemented the RBAC / Keys solution in a different way. (SOrry, I didn't know this was happening).

I pulled in the latest from upstream/main to jongio/main so you can see the difference.

Can you please do the analysis to figure out how we can merge the two and what the differences are in implementation?

@jongio
Copy link
Owner

jongio commented Jan 31, 2024

@zedy-wj - After the merge does the app now work?

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Feb 1, 2024

@jongio - The merged code works well during local deployment. Since the directory structure of the project has also changed, we are solving the deployment structure problem in the azure.yaml file.

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Feb 2, 2024

@jongio - We've updated the code and it's working fine so far, please re-review it, thanks!

azure.yaml Outdated Show resolved Hide resolved
code/app/app.py Show resolved Hide resolved
@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Feb 5, 2024

@jongio - We removed hooks and replaced them with structural changes in the code folder. Since the three services of web, adminweb, and function all require the utilities folder, we placed it in the innermost layer to ensure that other services are available during azd deploy. Currently both local deployment and azd deployment are working well, please re-review it, thanks!

@jongio
Copy link
Owner

jongio commented Feb 5, 2024

Thanks, I just updated main with latest from upstream, so there are merge conflicts now.

Can you give me an itemized list of the tests that you ran?

Like

  1. With RBAC
  2. With Keys
  3. With Keyvault = true
  4. etc

@zedy-wj
Copy link
Collaborator Author

zedy-wj commented Feb 6, 2024

@jongio - We resolved the conflict, and the update in upstream conflicts with our current code mainly in rbac. Since the upstream still uses an earlier version of OpenAI, this part retains the code in this PR.

Can you give me an itemized list of the tests that you ran?

At present, we have the following three tests in the list, and different parameters need to be configured:

  1. With RBAC

    • AZURE_AUTH_TYPE= rbac
    • USE_KEY_VAULT= false
  2. With Keys and not use Key Vault

    • AZURE_AUTH_TYPE= keys
    • USE_KEY_VAULT= false
  3. With Keys and use Key Vault

    • AZURE_AUTH_TYPE= keys
    • USE_KEY_VAULT= true

Note: The current default values ​​are: AZURE_AUTH_TYPE=keys and USE_KEY_VAULT=true.

@jongio jongio merged commit cf07644 into jongio:main Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants