Comments (12)
@oadrian2
Thanks for your feedback! We will investigate and update as appropriate.
from azure-docs.
Your feedback has been shared with the content owner for further review. Thanks again for the feedback!
from azure-docs.
@oadrian2 I'm not quite understand your question. SWA only support HttpTrigger
, that's why Web PubSub has a WebPubSubContext
to deserialize the Web PubSub service http request to Web PubSub protocol input object. What do you mean by tie event message to CosmosDB input? Why you need to make it a CosmosDB input when the request is actually from Web PubSub service?
from azure-docs.
I'm referring to cosmos DB inputs rather than triggers. Basically a way of a database query based on the event that was triggering of the web pub/sub similar to how you would with an HTTP request. With SignalR triggers, the parameters on the invocation can be mapped to cosmos DB bindings on the input which allows you to retrieve the data without having to actually invoke the client yourself.
from azure-docs.
Sorry I still couldn't get your idea. Would you share a sample code, maybe SignalR one that meet your ask?
from azure-docs.
This is the doing a pseudo-patch operation, which is invoked through a SignalR trigger. Non-relevant code has been omitted. Let me know if you want further clarification on anything. Thank you for taking the time.
const updateTokenInput = input.cosmosDB({
databaseName: DATABASE_NAME,
collectionName: TOKENS_CONTAINER,
connectionStringSetting: 'CosmosDBConnection',
id: '{token.id}', // using token triggerMetadata (see below)
partitionKey: '{mapId.game}', // using mapId triggerMetadata (see below)
});
//
app.generic('updateToken', {
trigger: trigger.generic({
type: 'signalRTrigger',
hubName: 'map',
category: 'messages',
event: 'updateToken',
// parameter names here will bind the arguments of the invoke to trigger bindings usable by inputs/outputs
parameterNames: ['mapId', 'token'],
}),
extraInputs: [updateTokenInput],
extraOutputs: [signalRMessagesOutput, tokenContainerOutput],
handler: async (_request, context) => {
const mapId = context.triggerMetadata!.mapId as { id: string; game: string }; // id coming from patch request
const token = context.triggerMetadata!.token as Token`; // patch data
const { id: map, game } = mapId;
const documentIn = (context.extraInputs.get(updateTokenInput) || {}) as object;
const documentOut = { ...documentIn, ...token };
context.extraOutputs.set(tokenContainerOutput, documentOut);
context.extraOutputs.set(signalRMessagesOutput, [
{
target: 'tokenUpdated', // event name
arguments: [mapId, documentOut], // arguments to event
},
]);
},
});
from azure-docs.
When work with WebPubSubTrigger
, triggerMetadata is all the metadata pre-bind with it, where you can refer to section https://learn.microsoft.com/en-us/azure/azure-web-pubsub/reference-functions-bindings?tabs=csharp#usages about available items under different requests.
I'm working on a chat sample under v4 model. And probably would help you easier get started.
from azure-docs.
You can refer to this chat sample: https://github.com/JialinXin/azure-webpubsub/tree/jixin/v4-js/samples/functions/js/simplechat_v4
from azure-docs.
When work with
WebPubSubTrigger
, triggerMetadata is all the metadata pre-bind with it, where you can refer to section https://learn.microsoft.com/en-us/azure/azure-web-pubsub/reference-functions-bindings?tabs=csharp#usages about available items under different requests.I'm working on a chat sample under v4 model. And probably would help you easier get started.
What about in the SWA-style HTTP triggers?
from azure-docs.
Then you need to work with WebPubSubContext
input binding and in the function, you can get the values by context.extraInputs.get('wpsContext')
. And inner structure is described here: https://learn.microsoft.com/en-us/azure/azure-web-pubsub/reference-functions-bindings?tabs=csharp#webpubsubcontext-1
For example:
const wpsContext= input.generic({
type: 'webPubSubContext',
name: 'wpsContext',
hub: 'sample_funcchatv4'
});
app.http('message', {
methods: ['GET', 'POST'],
authLevel: 'anonymous',
extraInputs: [wpsContext],
handler: async (request, context) => {
let wpsRequest = context.extraInputs.get('wpsContext').request;
let data = request.data;
....
},
});
from azure-docs.
Then you need to work with
WebPubSubContext
input binding and in the function, you can get the values bycontext.extraInputs.get('wpsContext')
. And inner structure is described here: https://learn.microsoft.com/en-us/azure/azure-web-pubsub/reference-functions-bindings?tabs=csharp#webpubsubcontext-1For example:
const wpsContext= input.generic({ type: 'webPubSubContext', name: 'wpsContext', hub: 'sample_funcchatv4' }); app.http('message', { methods: ['GET', 'POST'], authLevel: 'anonymous', extraInputs: [wpsContext], handler: async (request, context) => { let wpsRequest = context.extraInputs.get('wpsContext').request; let data = request.data; .... }, });
Is it the case that since the WebPubSubContext is an input and not a trigger, the trigger metadata isn't present like they are with the WebPubSubTrigger? If they aren't there when using WebPubSubContext then you can't use those values to populate other Input bindings (e.g., CosmosDB or Storage) since there isn't any binding metadata. This does limit its usefulness.
from azure-docs.
It's correct that WebPubSubContext
is an input binding instead of trigger binding, so triggerMetadata
is not valid for building WebPubSub metadata here. I'm not sure that if it's possible to bind single request to multiple input bindings. When you work with WebPubSubContext
, it means the request is a Web PubSub request, why would you treat it as a Cosmos DB document? Should it read the request and then convert to a Cosmos DB document in other way? Would you describe your scenario a little bit more?
from azure-docs.
Related Issues (20)
- Incorrect guidance for configuring Node.js on AppService for Windows Platform HOT 4
- Feature request for Vector Search Index (Embedding and Vector Values) HOT 2
- Download link for the latest version 1.2.5252 is downloading the version 1.2.5112 HOT 3
- Need to update to Data instead of catalog in admin steps HOT 4
- Issues az HOT 1
- Please consider including steps for rotating a customer managed key HOT 1
- Incorrect commands listed in the "View the VM instances in a scale set" section HOT 2
- blobfuse need network accessibility to Storage account. HOT 2
- Unclear answer to one of the questions: "How do connections to Azure Storage in the same region work?" HOT 3
- Outdated page specifics. HOT 3
- TLS 1.3 support clarification HOT 3
- `Enable the AGIC add-on in existing AKS cluster through Azure portal` - UI no longer existed?
- Download link for SSH host keys HOT 2
- Bad example
- Azure Storage Firewall Document need to be updated HOT 3
- Azure Container Instance group docs; does "create" with same properties restart the containers? HOT 1
- Cost for exporting a disk (.vhd) to local computer HOT 2
- Increase maximum parallel online backups HOT 1
- Incorrect API version for example code to call custom model name HOT 2
- Old Screenshot not relevant now. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from azure-docs.