-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: switch to Azure Functions v4 #177
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is looking pretty good! Just some small comments and requests for clarification. Unit tests are failing too, I think because we're writing some different files.
@@ -2,6 +2,6 @@ | |||
"version": "2.0", | |||
"extensionBundle": { | |||
"id": "Microsoft.Azure.Functions.ExtensionBundle", | |||
"version": "[2.*, 3.0.0)" | |||
"version": "[4.0.0, 5.0.0)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a external Azure function in this folder that also needs to be converted to the v4 model
] | ||
} | ||
`; | ||
const ssrFunctionRoute = '/api/sk_render'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The docs need to be updated to mention that this route is now reserved https://github.com/derkoe/svelte-adapter-azure-swa/blob/7a855e8885385ba12a8a71f603dc6f5e8537b732/README.md#L122-L123
return ipAddress; | ||
}, | ||
platform: { | ||
user: httpRequest.user, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
if (debug) { | ||
context.log(`SK headers: ${JSON.stringify(Object.fromEntries(rendered.headers.entries()))}`); | ||
context.log(`Response: ${JSON.stringify(rendered)}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not continue to log the response here?
* */ | ||
function toRequest(context) { | ||
const { method, headers, rawBody, body } = context.req; | ||
// because we proxy all requests to the render function, the original URL in the request is /api/__render |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we keep the comment?
headers: new Headers(headers), | ||
// @ts-ignore | ||
body: httpRequest.body, | ||
duplex: 'half' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why set this property?
const resCookies = []; | ||
|
||
headers.forEach((value, key) => { | ||
if (key === 'set-cookie') { | ||
const cookieStrings = set_cookie_parser.splitCookiesString(value); | ||
// @ts-ignore | ||
resCookies.push(...set_cookie_parser.parse(cookieStrings)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like this is due to a type mismatch on the sameSite
property - are we sure the sameSite
property returned by set_cookie_parser matches what Azure expects?
Type 'string' is not assignable to type '"Strict" | "Lax" | "None"'
if (method !== 'GET' && method !== 'HEAD') { | ||
init.body = Buffer.isBuffer(body) | ||
? body | ||
: typeof rawBody === 'string' | ||
? Buffer.from(rawBody, 'utf-8') | ||
: rawBody; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this logic isn't needed any more under the v4 model?
@derkoe no rush, but please re-request my review on the PR once you've addressed my comments - that way it doesn't get lost in my inbox |
* remove function.json - it is not needed anymore * rename function path to "sk_render" since v4 does not allow the path to start with "__" See also: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-version-4-of-the-node-js-programming-model-is-in/ba-p/3773541 closes geoffrich#159
9e297ea
to
4cbffd0
Compare
Guess I've addressed all the issues - sorry for the delay. (Also rebase on current main today). |
This switches to the new v4 runtime of Azure functions in Azure Static Webapps
See also: https://techcommunity.microsoft.com/t5/apps-on-azure-blog/azure-functions-version-4-of-the-node-js-programming-model-is-in/ba-p/3773541
closes #159