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
@@ -50,19 +50,20 @@ Open `Program.cs` file and add the following two lines of code to the top of the
50
50
```csharp
51
51
usingAzure.CloudMachine;
52
52
53
-
if (CloudMachineInfrastructure.Configure(args)) return;
53
+
CloudMachineInfrastructureinfrastrucutre=new();
54
+
if (infrastrucutre.TryExecuteCommand(args)) return;
54
55
```
55
-
The `CloudMachineInfrastructure.Configure` call allows running the app with a `-bicep` switch, which will generate bicep files required to provision CloudMachine resources in Azure. Let's generate these bicep files now.
56
+
57
+
The `TryExecuteCommand` call allows running the app with a `-init` switch, which will generate bicep files required to provision CloudMachine resources in Azure. Let's generate these bicep files now.
56
58
```dotnetcli
57
-
dotnet run -bicep
59
+
dotnet run -init
58
60
```
59
61
As you can see, a folder called `infra` was created with several bicep files in it. Let's now initialize the project.
62
+
60
63
```dotnetcli
61
64
azd init
62
65
```
63
-
select template, choose 'yes' when asked 'Continue initializing an app here?', choose the 'minimal' template, and use 'cmserver' as the environment name
64
-
65
-
Once the initialization completes, let's provision the resources. Select `eastus` as the region
66
+
type 'demo' as the environment name, and then let's provision the resources (select `eastus` as the region):
66
67
```dotnetcli
67
68
azd provision
68
69
```
@@ -77,213 +78,53 @@ az resource list --resource-group <resource_group_from_command_line> --output ta
77
78
78
79
#### Use CDK to add resources to the CloudMachine
79
80
80
-
Since we are writing an AI application, we need to provision Azure OpenAI resources. To do this, add the follwoing class to the end of the `Program.cs` file:
Then change the configuration call at the beginning of the file to:
81
+
Since we are writing an AI application, we need to provision Azure OpenAI resources. To do this, add the follwoing line of code right below where the infrastructure instance is created:
89
82
```csharp
90
-
if (CloudMachineInfrastructure.Configure(args, AssistantService.Configure)) return;
#### Add CloudMachineClient to ASP.NET DI Container
92
+
You will be using `CloudMachineClient` to access rources provisioned in the cloud machine. Let's add such client to the DI container such that it is avaliable to ASP.NET handlers
93
+
```dotnetcli
94
+
builder.AddCloudMachine(infrastrucutre);
95
+
```
98
96
#### Call CloudMachine APIs
99
97
100
-
You are now ready to call Azure OpenAI service from the app. To do this, add `CloudMachineClient` field and a `Chat` method to `AssistantService`:
And change the `Program.cs` file to the following, replacing the client URI with the URI in your server's launchsettings.json file ('cmdemo\server\Properties' folder)
0 commit comments