Skip to content

Commit 99f08bb

Browse files
authored
Merge pull request #12 from Azure-Samples/readme
Match the template README closer
2 parents 66afa7a + dbe25c3 commit 99f08bb

File tree

1 file changed

+85
-7
lines changed

1 file changed

+85
-7
lines changed

README.md

Lines changed: 85 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,91 @@ urlFragment: azure-openai-keyless-python
1515
-->
1616
# Azure OpenAI Keyless Deployment
1717

18+
[![Open in GitHub Codespaces](https://img.shields.io/static/v1?style=for-the-badge&label=GitHub+Codespaces&message=Open&color=brightgreen&logo=github)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&skip_quickstart=true&machine=basicLinux32gb&repo=784926917&devcontainer_path=.devcontainer%2Fdevcontainer.json&geo=WestUs2)
19+
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/azure-openai-keyless-python)
20+
1821
The purpose of this repository is to provision an Azure OpenAI account with an RBAC role permission for your user account to access,
1922
so that you can use the OpenAI API SDKs with keyless (Entra) authentication. By default, the account will include a gpt-3.5 model, but you can modify `infra/main.bicep` to deploy other models instead.
2023

21-
## Prerequisites
24+
* [Getting started](#getting-started)
25+
* [GitHub Codespaces](#github-codespaces)
26+
* [VS Code Dev Containers](#vs-code-dev-containers)
27+
* [Local environment](#local-environment)
28+
* [Deployment](#deployment)
29+
* [Running the Python example](#running-the-python-example)
30+
* [Guidance](#guidance)
31+
* [Costs](#costs)
32+
* [Security guidelines](#security-guidelines)
33+
* [Resources](#resources)
34+
35+
## Getting started
36+
37+
You have a few options for getting started with this template.
38+
The quickest way to get started is GitHub Codespaces, since it will setup all the tools for you, but you can also [set it up locally](#local-environment).
39+
40+
### GitHub Codespaces
41+
42+
You can run this template virtually by using GitHub Codespaces. The button will open a web-based VS Code instance in your browser:
43+
44+
1. Open the template (this may take several minutes):
45+
46+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/azure-openai-keyless-python)
47+
48+
2. Open a terminal window
49+
3. Continue with the [deployment steps](#deployment)
50+
51+
### VS Code Dev Containers
2252

23-
1. Sign up for a [free Azure account](https://azure.microsoft.com/free/) and create an Azure Subscription.
24-
2. Request access to Azure OpenAI Service by completing the form at [https://aka.ms/oai/access](https://aka.ms/oai/access) and awaiting approval.
25-
3. Install the [Azure Developer CLI](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd). (If you open this repository in Codespaces or with the VS Code Dev Containers extension, that part will be done for you.)
53+
A related option is VS Code Dev Containers, which will open the project in your local VS Code using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers):
2654

27-
## Provisioning
55+
1. Start Docker Desktop (install it if not already installed)
56+
2. Open the project:
57+
58+
[![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/azure-samples/azure-openai-keyless-python)
59+
60+
3. In the VS Code window that opens, once the project files show up (this may take several minutes), open a terminal window.
61+
4. Continue with the [deployment steps](#deployment)
62+
63+
### Local environment
64+
65+
1. Make sure the following tools are installed:
66+
67+
* [Azure Developer CLI (azd)](https://aka.ms/install-azd)
68+
* [Python 3.9+](https://www.python.org/downloads/)
69+
70+
2. Make a new directory called `azure-openai-keyless-python` and clone this template into it using the `azd` CLI:
71+
72+
```shell
73+
azd init -t azure-openai-keyless-python
74+
```
75+
76+
You can also use git to clone the repository if you prefer.
77+
78+
3. Continue with the [deployment steps](#deployment)
79+
80+
## Deployment
2881

2982
1. Login to Azure:
3083

3184
```shell
3285
azd auth login
3386
```
3487

88+
For GitHub Codespaces users, if the previous command fails, try:
89+
90+
```shell
91+
azd auth login --use-device-code
92+
```
93+
3594
2. Provision the OpenAI account:
3695

3796
```shell
3897
azd provision
3998
```
4099

41-
It will prompt you to provide an `azd` environment name (like "chat-app"), select a subscription from your Azure account, and select a [location where the OpenAI model is available](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) (like "canadaeast"). Then it will provision the resources in your account and deploy the latest code. If you get an error or timeout with deployment, changing the location can help, as there may be availability constraints for the OpenAI resource. To change the location run:
100+
It will prompt you to provide an `azd` environment name (like "chat-app"), select a subscription from your Azure account, and select a [location where the OpenAI model is available](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#standard-deployment-model-availability) (like "canadaeast"). Then it will provision the resources in your account and deploy the latest code.
101+
102+
⚠️ If you get an error or timeout with deployment, changing the location can help, as there may be availability constraints for the OpenAI resource. To change the location run:
42103

43104
```shell
44105
azd env set AZURE_LOCATION "yournewlocationname"
@@ -58,7 +119,7 @@ so that you can use the OpenAI API SDKs with keyless (Entra) authentication. By
58119
pwsh ./write_dot_env.ps1
59120
```
60121

61-
4. Then you can run the example code in this repository.
122+
4. Then you can proceed to [run the Python example](#running-the-python-example).
62123

63124
## Running the Python example
64125

@@ -77,3 +138,20 @@ so that you can use the OpenAI API SDKs with keyless (Entra) authentication. By
77138
```
78139
79140
This will use the OpenAI API SDK to make a request to the OpenAI API and print the response.
141+
142+
## Guidance
143+
144+
### Costs
145+
146+
This template creates only the Azure OpenAI resource, which is free to provision. However, you will be charged for the usage of the Azure OpenAI chat completions API. The pricing is based on the number of tokens used, with around 1-3 tokens used per word. You can find the pricing details for the OpenAI API on the [Azure Cognitive Services pricing page](https://azure.microsoft.com/pricing/details/cognitive-services/openai-service/).
147+
148+
### Security guidelines
149+
150+
This template uses [keyless authentication](https://learn.microsoft.com/en-us/azure/developer/ai/keyless-connections) for authenticating to the Azure OpenAI resource. This is a secure way to authenticate to Azure resources without needing to store credentials in your code. Your Azure user account is assigned the "Cognitive Services OpenAI User" role, which allows you to access the OpenAI resource. You can find more information about the permissions of this role in the [Azure OpenAI documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/how-to/role-based-access-control).
151+
152+
For further security, you could also deploy the Azure OpenAI inside a private virtual network (VNet) and use a private endpoint to access it. This would prevent the OpenAI resource from being accessed from the public internet.
153+
154+
## Resources
155+
156+
* [Video: Using keyless auth with Azure AI services](https://www.youtube.com/watch?v=IkDcQvKoQ8k)
157+
* [Sample app: Azure OpenAI + Container Apps + Managed Identity](https://github.com/Azure-Samples/openai-chat-app-quickstart)

0 commit comments

Comments
 (0)