You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Azure.Projects is an set of libraries and tools for rapid application development on Azure.
4
+
If you cannot get an app running in 10 minutes, let us know that we failed!
4
5
5
-
## Getting started
6
-
7
-
### Install the packages
6
+
These libraries and tools make it easier to start building an application, by:
7
+
- Relying on opinionated defaults whenever possible.
8
+
- Using the Azure.Provisioning libraries for provisioning resources in code (in C#).
9
+
- Exposing simplified APIs for the most commonly used Azure services.
8
10
9
-
Install the client library for .NET with [NuGet](https://www.nuget.org/):
11
+
At the same time, Azure.Projects supports break-glass scenarios where, if needed, you can override the defaults, use powerful tools (like bicep, azd), or the full featured Azure SDK libraries.
12
+
In other words, Azure.Projects provides smart, simplified APIs but will never block you from using the full power of the Azure platform, if you choose to.
The `TryExecuteCommand` call allows running the app with a `-init` switch, which will generate bicep files required to provision project resources in Azure. Let's generate these bicep files now.
61
-
```dotnetcli
62
-
dotnet run -bicep
63
-
```
64
-
As you can see, a folder called `infra` was created with several bicep files in it. Let's now initialize the project.
55
+
if (args.Length>0&&args[0] =="-bicep")
56
+
{
57
+
Azd.Init(infrastructure);
58
+
return;
59
+
}
60
+
61
+
ProjectClientproject=new();
62
+
ChatClientchat=project.GetOpenAIChatClient();
63
+
Console.WriteLine(chat.CompleteChat("list all noble gasses.").AsText());
65
64
66
-
```dotnetcli
67
-
azd init
68
-
```
69
-
type 'demo' as the environment name, and then let's provision the resources (select `eastus` as the region):
70
-
```dotnetcli
71
-
azd provision
72
-
```
73
-
When provisioning finishes, you should see something like the following in the console output
And if you go to your Azure portal, or execute the following az command, you can see the resource group created. The resource group will contain resources such as Storage, ServiceBus, and EventGrid.
78
-
```dotnetcli
79
-
az resource list --resource-group <resource_group_from_command_line> --output table
80
65
```
81
66
82
-
#### Use CDK to add resources to the Project
67
+
You can now provision Azure resources for this application by executing the following three commands.
83
68
84
-
Since we are writing an AI application, we need to provision Azure OpenAI resources. To do this, add the following line of code right below where the infrastructure instance is created:
You will be using `ProjectClient` to access resources provisioned in the cloud machine. Let's add such client to the DI container such that it is avaliable to ASP.NET handlers
74
+
The first command created a folder called `infra` with several bicep files in it. The files will be used by azd to provision Azure resources.
75
+
The second command sets initializes the project as an azd project. Select 'create minimal project' when asked to choose a template, and type 'demo' as the environment name.
76
+
The last command actually provisions resources described by the bicep files. When provisioning finishes, you should see something like the following in the console output
96
77
```dotnetcli
97
-
builder.AddAzureProjectClient(infrastructure);
98
-
```
99
-
#### Call ProjectClient APIs
100
-
101
-
You are now ready to call Azure OpenAI service from the app. To do this, change the line of code that maps the application root to the following:
102
-
103
-
```csharp
104
-
app.MapGet("/", (ProjectClientclient) =>client.GetOpenAIChatClient().CompleteChat("list all noble gases").AsText());
105
-
```
106
-
107
-
The full program should now look like the following:
0 commit comments