To build this solution you will need:
- An Azure subscription - Create one for free
- Access granted to Azure OpenAI in the desired Azure subscription
- A GitHub account and basic git knowledge to create repositories and commit files.
Currently, access to this service is granted only by application. You can apply for access to Azure OpenAI by completing the form at https://aka.ms/oai/access. Open an issue on this repo to contact us if you have an issue.
-
Navigate to the create page: Azure OpenAI Service Create Page
-
On the Create page provide the following information:
Field Description Subscription Select the Azure subscription used in your OpenAI onboarding application Resource group The Azure resource group that will contain your OpenAI resource. You can create a new group or add it to a pre-existing group. Region The location of your instance. Different locations may introduce latency, but have no impact on the runtime availability of your resource. Name A descriptive name for your Azure services resource. For example, MyQuoteGeneratorOpenAI. Pricing Tier Only 1 pricing tier is available for the service currently
Before you can generate text or inference, you need to deploy a model. You can select from one of several available models in Azure OpenAI Studio.
To deploy a model, follow these steps:
- Sign in to Azure OpenAI Studio.
- Select the subscription and Azure OpenAI resource to work with.
- Under Management select Deployments.
- Select Create new deployment.
- Select either gpt-35-turbo or gpt-35-turbo-16k as a base model from the drop-down.
- Enter a deployment name to help you identify the model. Save the name. as it will be used within the Azure Logic App to call the model via the REST API.
- For your first deployment leave the Advanced Options set to the defaults.
The deployments table displays a new entry that corresponds to this newly created model. Your deployment status will move to succeeded when the deployment is complete and ready for use.
To call our model via REST API from the Logic App, we need to copy the endpoint and key.\
- Navigate to the OpenAI Settings page on Azure AI Studios' up right corner (cog icon). Click the Resource tab.
- Select your resource and copy the endpoint value.
- Click the eye icon on the Key column and copy the key value.
-
Navigate to the create page: Azure Logic App Create Page
-
On the Create Logic App page provide the following information:
Field Description Subscription Select your Azure subscription Resource group Select the Resource Group craeted in the steps above. Logic App Name A descriptive name for your Azure Logic App resource. For example, MyQuoteGeneratorLogicApp. Publish Pick Workflow. Region The location of your instance. For latency resons, pick the same region where your OpenAI instance was created or the closest one possible. Plan type For this simple demo, you can pick Consumption, for production deployments, consider a Standard plan. Keep the other default selections by clicking Review + Create, review your selections and click Create after validation.
-
Navigate to the Logic App code view.
-
Copy the content from workflow.json and paste it as your Logic App code. Replace <OPENAI_ENDPOINT>, <OPENAI_MODEL> and _<OPENAI_KEY>_with the endpoint, model, and key from your OpenAI deployment, captured in the OpenAI Deployment step above.
-
Click Save.
-
Go to the Logic App Designer, select the When a HTTP request is received and copy the HTTP POST URL value from it. We will use it in our HTML file, later.
We will create a very simple website to host an HTML file, connected to a new GitHub repository. For a more detailed tutorial on how to deploy static web apps using popular frameworks like Angular, Blazor, React and Vue, or to connect to an Azure DevOps repository, follow this guide.
- Follow the Create a repo tutorial to create a new repository.
- Copy the contents of index.html or download it.
- Create a file with the same name within your repository's main branch. Replace <LOGIC_APP_URL> with the value from our Logic App HTTP POST URL.
- Go to the Azure portal.
- Select Create a Resource.
- Search for Static Web Apps.
- Select Static Web Apps.
- Select Create.
In the Basics section, begin by configuring your new app and linking it to a GitHub repository.
Setting | Value |
---|---|
Subscription | Select your Azure subscription. |
Resource Group | Select the same resource group created in the beginning of the tutorial, or create a new one. |
Name | Enter a name for your resource. You can use my-quote-creator-web-app in the textbox,for example. |
Plan type | Select Free. |
Azure Functions and staging details | Select a region closest to your previous deployments. |
Source | Select GitHub. |
Select Sign-in with GitHub and authenticate with GitHub.
After you sign in with GitHub, enter the repository information.
Setting | Value |
---|---|
Organization | Select your organization. |
Repository | Select your repository name. |
Branch | Select <branch_name>. |
Note
If you don't see any repositories:
- You may need to authorize Azure Static Web Apps in GitHub. Browse to your GitHub repository and go to Settings > Applications > Authorized OAuth Apps, select Azure Static Web Apps, and then select Grant.
In the Build Details section, add configuration details specific to your preferred front-end framework.
- Select Custom from the Build Presets dropdown.
- Type / in the App location box.
- Leave the Api location box empty.
- Type / App artifact location box.
Select Review + create.
There are two aspects to deploying a static app. The first creates the underlying Azure resources that make up your app. The second is a workflow that builds and publishes your application.
Before you can go to your new static site, the deployment build must first finish running.
The Static Web Apps Overview window displays a series of links that help you interact with your web app.
- Selecting on the banner that says, Select here to check the status of your GitHub Actions runs takes you to the GitHub Actions running against your repository. Once you verify the deployment job is complete, then you can go to your website via the generated URL.
- Once GitHub Actions workflow is complete, you can select the URL link to open the website in new tab.
- Add comma-separated keywords in the input box and click Build.
- After a few seconds, you'll see your quote with a related image in the background.
- Protect your resources with [VNets](Azure Virtual Private Network), Managed Identity authentication and authrization.
- Keep sensitive data like service endpoints and keys protected by using Azure Key Vault as an alternative.
If you're not going to continue to use this application, you can delete all your resurces through the following steps:
- Open the Azure portal.
- Search for your Resource Group name from the top search bar. Open it.
- Click Delete resource group.
- Type the name of your resource group at the input box and click Delete.