Skip to content

Commit f35930f

Browse files
authored
Update use-aadhttpclient-enterpriseapi.md
Update use-aadhttpclient-enterpriseapi.md to match behavior of new Azure portal, behavior of yeoman generator to match tutorial story which does not request that web part is deployed to site before usage.
1 parent 145d344 commit f35930f

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

docs/spfx/use-aadhttpclient-enterpriseapi.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,13 @@ In the Function App, you will create a new HTTP-triggered function. In this exam
2626

2727
In the Function App, press the **New Function** button:
2828

29-
3029
![The 'Create new' button highlighted in the Azure portal](../images/use-aadhttpclient-enterpriseapi-create-function.png)
3130

32-
Next, click the **Custom function** link to create a custom HTTP-triggered function:
33-
34-
![The 'Custom function' link highlighted in the Azure portal](../images/use-aadhttpclient-enterpriseapi-create-function-custom-function.png)
35-
3631
From the list of templates, choose **HTTP trigger**:
3732

3833
![The 'HTTP trigger' function template highlighted in the Azure portal](../images/use-aadhttpclient-enterpriseapi-create-function-http-trigger.png)
3934

40-
In the New Function panel, choose **C#** as the language, specify the function name, set the **Authorization level** to **Anonymous**, and click the **Create** button:
35+
In the New Function panel, specify the function name, set the **Authorization level** to **Anonymous**, and click the **Create** button:
4136

4237
![Settings for the new Azure function in the Azure portal](../images/use-aadhttpclient-enterpriseapi-create-function-settings.png)
4338

@@ -46,13 +41,20 @@ In the New Function panel, choose **C#** as the language, specify the function n
4641
Once the function is created, replace its contents with the following snippet:
4742

4843
```cs
44+
#r "Newtonsoft.Json"
45+
4946
using System.Net;
47+
using Microsoft.AspNetCore.Mvc;
48+
using Microsoft.Extensions.Primitives;
49+
using Newtonsoft.Json;
5050

51-
public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceWriter log)
51+
public static async Task<IActionResult> Run(HttpRequest req, ILogger log)
5252
{
53-
log.Info("C# HTTP trigger function processed a request.");
53+
log.LogInformation("C# HTTP trigger function processed a request.");
54+
55+
string name = req.Query["name"];
5456

55-
return req.CreateResponse(HttpStatusCode.OK, new List<object> {
57+
return (ActionResult)new OkObjectResult(new List<object> {
5658
new {
5759
Id = 1,
5860
OrderDate = new DateTime(2016, 1, 6),
@@ -105,6 +107,7 @@ public static async Task<HttpResponseMessage> Run(HttpRequestMessage req, TraceW
105107
}
106108
});
107109
}
110+
108111
```
109112

110113
Verify that the function is working correctly, by pressing the **Save and run** button:
@@ -230,7 +233,7 @@ When prompted, use the following values:
230233
- **What is your solution name?** contoso-api
231234
- **Which baseline packages do you want to target for your component(s)?** SharePoint Online only (latest)
232235
- **Where do you want to place the files?** Use the current folder
233-
- **Do you want to allow the tenant admin the choice of being able to deploy the solution to all sites immediately without running any feature deployment or adding apps in sites?** No
236+
- **Do you want to allow the tenant admin the choice of being able to deploy the solution to all sites immediately without running any feature deployment or adding apps in sites?** Yes
234237
- **Will the components in the solution require permissions to access web APIs that are unique and not shared with other components in the tenant?** No
235238
- **Which type of client-side component to create?** WebPart
236239
- **What is your Web part name?** Orders
@@ -260,9 +263,10 @@ In the **solution** property, add a new property named `webApiPermissionRequests
260263
"version": "1.0.0.0",
261264
"includeClientSideAssets": true,
262265
"skipFeatureDeployment": true,
266+
"isDomainIsolated": false,
263267
"webApiPermissionRequests": [
264268
{
265-
"resource": "contoso-api",
269+
"resource": "contoso-api-dp20191109",
266270
"scope": "user_impersonation"
267271
}
268272
]
@@ -311,7 +315,7 @@ export default class OrdersWebPart extends BaseClientSideWebPart<IOrdersWebPartP
311315
protected onInit(): Promise<void> {
312316
return new Promise<void>((resolve: () => void, reject: (error: any) => void): void => {
313317
this.context.aadHttpClientFactory
314-
.getClient('594e83da-9618-438f-a40a-4a977c03bc16')
318+
.getClient('6bc8bca8-5866-405d-b236-9200bdbb73c0')
315319
.then((client: AadHttpClient): void => {
316320
this.ordersClient = client;
317321
resolve();
@@ -334,7 +338,7 @@ export default class OrdersWebPart extends BaseClientSideWebPart<IOrdersWebPartP
334338
protected onInit(): Promise<void> {
335339
return new Promise<void>((resolve: () => void, reject: (error: any) => void): void => {
336340
this.context.aadHttpClientFactory
337-
.getClient('594e83da-9618-438f-a40a-4a977c03bc16')
341+
.getClient('6bc8bca8-5866-405d-b236-9200bdbb73c0')
338342
.then((client: AadHttpClient): void => {
339343
this.ordersClient = client;
340344
resolve();
@@ -346,7 +350,7 @@ export default class OrdersWebPart extends BaseClientSideWebPart<IOrdersWebPartP
346350
this.context.statusRenderer.displayLoadingIndicator(this.domElement, 'orders');
347351

348352
this.ordersClient
349-
.get('https://contoso-apis.azurewebsites.net/api/Orders', AadHttpClient.configurations.v1)
353+
.get('https://contoso-api-dp20191109.azurewebsites.net/api/Orders', AadHttpClient.configurations.v1)
350354
.then((res: HttpClientResponse): Promise<any> => {
351355
return res.json();
352356
})
@@ -360,7 +364,7 @@ export default class OrdersWebPart extends BaseClientSideWebPart<IOrdersWebPartP
360364
<span class="${ styles.title}">Orders</span>
361365
<p class="${ styles.description}">
362366
<ul>
363-
${orders.map(o => `<li>${o.Rep} $${o.Total}</li>`).join('')}
367+
${orders.map(o => `<li>${o.rep} $${o.total}</li>`).join('')}
364368
</ul>
365369
</p>
366370
<a href="https://aka.ms/spfx" class="${ styles.button}">

0 commit comments

Comments
 (0)