-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from Yvand/releases/1.0.0.rc-7
Publish 1.0.0.rc 7
- Loading branch information
Showing
11 changed files
with
192 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
name: functions-quickstart-spo-azd | ||
metadata: | ||
template: Yvand/[email protected]6 | ||
template: Yvand/[email protected]7 | ||
services: | ||
api: | ||
project: . | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { HttpRequest, HttpResponseInit, InvocationContext } from "@azure/functions"; | ||
import "@pnp/sp/items/index.js"; | ||
import "@pnp/sp/lists/index.js"; | ||
import "@pnp/sp/subscriptions/index.js"; | ||
import "@pnp/sp/webs/index.js"; | ||
import { CommonConfig, safeWait } from "../utils/common.js"; | ||
import { logError } from "../utils/loggingHandler.js"; | ||
import { getSharePointSiteInfo, getSpAccessToken, getSPFI } from "../utils/spAuthentication.js"; | ||
|
||
export async function getAccessToken(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> { | ||
const tenantPrefix = request.query.get('tenantPrefix') || CommonConfig.TenantPrefix; | ||
try { | ||
const token = await getSpAccessToken(tenantPrefix); | ||
let result: any = { | ||
userAssignedManagedIdentityClientId: CommonConfig.UserAssignedManagedIdentityClientId, | ||
tenantPrefix: tenantPrefix, | ||
sharePointDomain: CommonConfig.SharePointDomain, | ||
token: token, | ||
}; | ||
return { status: 200, jsonBody: result }; | ||
} | ||
catch (error: unknown) { | ||
const errorDetails = await logError(context, error, context.functionName); | ||
return { status: errorDetails.httpStatus, jsonBody: errorDetails }; | ||
} | ||
}; | ||
|
||
export async function getWeb(request: HttpRequest, context: InvocationContext): Promise<HttpResponseInit> { | ||
try { | ||
const tenantPrefix = request.query.get('tenantPrefix') || undefined; | ||
const siteRelativePath = request.query.get('siteRelativePath') || undefined; | ||
const sharePointSite = getSharePointSiteInfo(tenantPrefix, siteRelativePath); | ||
const sp = getSPFI(sharePointSite); | ||
let result: any, error: any; | ||
[result, error] = await safeWait(sp.web()); | ||
if (error) { | ||
const errorDetails = await logError(context, error, `Could not get web for tenantPrefix '${sharePointSite.tenantPrefix}' and site '${sharePointSite.siteRelativePath}'`); | ||
return { status: errorDetails.httpStatus, jsonBody: errorDetails }; | ||
} | ||
return { status: 200, jsonBody: result }; | ||
} | ||
catch (error: unknown) { | ||
const errorDetails = await logError(context, error, context.functionName); | ||
return { status: errorDetails.httpStatus, jsonBody: errorDetails }; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { app } from "@azure/functions"; | ||
import { getAccessToken, getWeb } from "../debug/funcs-debug-impl.js"; | ||
|
||
app.http('debug-getAccessToken', { methods: ['GET'], authLevel: 'admin', handler: getAccessToken, route: 'debug/getAccessToken' }); | ||
app.http('debug-getWeb', { methods: ['GET'], authLevel: 'function', handler: getWeb, route: 'debug/getWeb' }); |
2 changes: 1 addition & 1 deletion
2
...unctions-definition/webhooks-functions.ts → ...unctions-definition/funcs-webhooks-def.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.