Skip to content

Instantly share code, notes, and snippets.

View captainsafia's full-sized avatar

Safia Abdalla captainsafia

View GitHub Profile
@captainsafia
captainsafia / aspire-azure-functions-resources.md
Created November 13, 2024 00:36
Resources on the Aspire + Azure Functions integration for .NET Conf 2024

Note

The details shared here are based on the prototyping done as of 2/3/2024. If you're reading this gist at a later time, the details might have changed. In any case, it's here for archival reasons.

This gist is written in response to a tweet by Adam Storr (@WestDiscGolf) in response to a code sample that was shared of the current prototype of our workstream to sharpen up event-based apps.

Sure. The "with provider" and "map events" methods, how they work together and are processed under the hood. For example when/how a message arrives and triggers the binding/handler. Thanks for your reply :-)

The prototype code looks like this:

@captainsafia
captainsafia / Program.cs
Last active December 11, 2023 06:57
Titan: the small but mighty API framework (requires .NET 7)
using System.Net;
using System.Text;
var port = 8080;
var server = new Server(port);
server.UseAuthentication();
server.UseRouting();
server.UseNotFoundPage();
make: Entering directory '/home/captainsafia/github.com/dotnet/runtime/src/mono/wasm'
/home/captainsafia/github.com/dotnet/runtime/dotnet.sh build --configuration debug --nologo /p:TargetArchitecture=wasm /p:TargetOS=Browser /p:Configuration=Debug /p:RuntimeConfiguration=Release /home/captainsafia/github.com/dotnet/runtime/src/mono/wasm/debugger/tests/debugger-test
Determining projects to restore...
All projects are up-to-date for restore.
Determining projects to restore...
All projects are up-to-date for restore.
WasmAppBuilder -> /home/captainsafia/github.com/dotnet/runtime/artifacts/bin/WasmAppBuilder/Debug/net5.0/WasmAppBuilder.dll
WasmAppBuilder -> /home/captainsafia/github.com/dotnet/runtime/artifacts/bin/WasmAppBuilder/Debug/net5.0/publish/
debugger-test -> /home/captainsafia/github.com/dotnet/runtime/artifacts/bin/debugger-test/wasm/Debug/debugger-test.dll
This file has been truncated, but you can view the full file.
ãÏΩ `$YY/>=3;≥3ô˜˚π€Û⁄I≤ìÓŒ£ìÃÑ:ùN¶ôºHw2+Œ⁄V∫+IÌTW5U’yÃ≤¿" Ëe—ã¢"EPƒ'ˇ{UTƒr≈+
xˇ»S\‰≠ÇäWÓy’˚‘©Í$›]=ª∞ªIͺæsŒÔ˚ŒwæÛùÔÏ⁄≤eK€Cs√Ç4./é
"?ÕiK≈gU^Q„EÆ¢qǧr _ÊaA(rö Kj|X‰Ó»©ëë˘û‚í¨jÒØÄ Ò≤:_ƒRl^êDyÒøæ˜ΩÔÌGˇ˘û◊"{@”ú≤Z_‰ïüyÈÊî¡O‹ª5“ˆ–±tUQxIõÕ¶´¢VU¯áx©k6WsùÉ?•◊È€7 ©ã™ßh|)y Ú8≠Û¯\.=5í)åeÛÖTÓ∆t*ó+LÇkÒT•"›û‘*'FsZµ$»—¥\‚c\•OÀíHU„£
WÊWdÂ∂áâ—κX·ïh˚ /ïxÖW:ÏŸ'∏‚TŒ#ÁÖâ¢v\ÊJBQëUyAÀs "Ø©3<Wö탵ÌöRÂ#ÖÁ–ÊkQ–ñ™Û±¢\éódM‚µ8ßV¿è¢¨Ò˘ÑÏzx:]OçÂ∂%V€¶s›üå¥õπ;¢óFª¯XEëÀ≠PSQ( ¢¨®fl_`y‰Ò«/Ω¯“¬ÓKèÌΩÙ¯•ˆÓûπÃN…Ω,(=^Z~‰ÒK›=Àó¢±éK̜Ҡè?]S´≈"Ø™è<ÓìèWYy‰Ò;•`Æ5ûdÕ.D∑èß&«⁄x©0õãÕÊGª˜LŒM“#x∂vΩH>33QòûôõIMÊ23πÏ‘‰éÓXfl@¨˜¿»T~2ì/\ü Â ”©¸ı
}zj|j∂∏ Œ%Í—˛Ù‘‰H™êæÕÄ…ÿ*…˜‰Æg∆«ÔçæäflQóvéOçM¶&2{¨ÕÇ<„s„ëfi˚çÈÒl!üœLdÚ3flW»er∞Ÿëã=•~`a`æ´Øßo°´Ø/¡u]MÙp] Ω|i†o`∞ƒœóv‰'¶G≤3›ÒeNâ/»b ˆ±‘_Ë}°tµwMÍÔª3∏ÿ/ˆı]]],™} øE)ûèü®ùÕéè‰S3cô¸‘l~z6àÀNé!∞Ó'®Œç‹P°®ππÓÒSK∑„…X"÷ùHt)≈Xw¨'—óËçu_çÁJ∑’623SS˘¡ı∂±"c8;ŸC´ &-ó°PTë`ê«óª˚bÄ$8KßÊ≤3˘Ÿ‘x!39W…ÊR√„à©âȸ÷Óû6ãòyAmfÜW™"?Û´‡+¶t(^Tÿè€NUcÍ“ 2≥„˘Ïxf.3^üö∫1;IϱÇ|«≤Z

Scenario 0: Debugging standalone application

  1. Create a new Blazor WASM application from the CLI using dotnet new blazorwasm -o Scenario0

  2. Open the "Scenario0" directory in VS Code.

  3. Navigate to the "Debug" section on the left. Then, click "create a launch.json file". In the window that pops up, select "Blazor WebAssembly Debug".

    image-20200517115925932
  4. A new launch.json file should be created with the following contents.

{"timestamp":1589821464413,"tag":"runtime.welcome","level":1,"message":"js-debug-nightly v2020.5.1517 started","metadata":{"os":"darwin x64","nodeVersion":"v12.8.1","adapterVersion":"2020.5.1517"}}
{"tag":"dap.receive","timestamp":1589821464390,"metadata":{"connectionId":2,"message":{"command":"initialize","arguments":{"clientID":"vscode","clientName":"Visual Studio Code","adapterID":"pwa-chrome","pathFormat":"path","linesStartAt1":true,"columnsStartAt1":true,"supportsVariableType":true,"supportsVariablePaging":true,"supportsRunInTerminalRequest":true,"locale":"en-us","supportsProgressReporting":true},"type":"request","seq":1}},"level":0}
{"tag":"dap.send","timestamp":1589821464391,"metadata":{"connectionId":2,"message":{"seq":1,"type":"response","request_seq":1,"command":"initialize","success":true,"body":{"supportsConfigurationDoneRequest":true,"supportsFunctionBreakpoints":false,"supportsConditionalBreakpoints":true,"supportsHitConditionalBreakpoints":true,"supportsEvaluateForHovers":true,"exceptionBreakpo
/** Launch a new kernel when the app host token changes. **/
const launchKernelWhenTokenChanged = (action$, state$) =>
// Whenever a new kernel is launched we execute this logic
action$.pipe(ofType("LAUNCH_KERNEL_SUCCESSFUL"),
switchMap((action) =>
// We subscribe to the StateObservable, which is a stream of changes to the Redux state
state$.pipe(
// We pull out the property we care about, the token field in the core state
pluck("app", "host", "token"),
// We only move on to the next step if it has changed https://www.learnrxjs.io/operators/filtering/distinctuntilchanged.html
export const updateDisplayEpic = (
action$: ActionsObservable<
actions.NewKernelAction | actions.KillKernelSuccessful
>
) =>
// Global message watcher so we need to set up a feed for each new kernel
action$.pipe(
ofType(actions.LAUNCH_KERNEL_SUCCESSFUL),
switchMap(
(action: actions.NewKernelAction | actions.KillKernelSuccessful) =>