Skip to content
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

CosmosDB input binding - InvocationContext.UserId #843

Open
jsquire opened this issue Apr 24, 2023 · 0 comments
Open

CosmosDB input binding - InvocationContext.UserId #843

jsquire opened this issue Apr 24, 2023 · 0 comments

Comments

@jsquire
Copy link
Member

jsquire commented Apr 24, 2023

Issue Transfer

This issue has been transferred from the Azure SDK for .NET repository, #35762.

Please be aware that @tonyhallett is the author of the original issue and include them for any questions or replies.

Details

Library name and version

Microsoft.Azure.WebJobs.Extensions.SignalRService ( 1.9.0 ), Microsoft.Azure.WebJobs.Extensions.CosmosDB ( 4.2.0), Microsoft.NET.Sdk.Functions ( 4.1.3)

Describe the bug

Given a generic ServerlessHub that successfully negotiates I have the following function invoked from the signalR client

        [FunctionName(nameof(InitialPlayerData))]
        public Task InitialPlayerData(
            [SignalRTrigger] InvocationContext invocationContext,
            [CosmosDB("Crib", "Players", Connection = "CosmosConnectionString", Id = "{UserId}", PartitionKey = "{UserId}")] Player player,
            ILogger logger)
        {
           .....

        }

image

Can I bind the UserId parameter ?

I checked with ChatGPT and it agreed that the CosmosDB attribute appeared correct.

If I change to using the CosmosClient directly the function is executed

        [FunctionName(nameof(InitialPlayerData))]
        async public Task InitialPlayerData(
            [SignalRTrigger] InvocationContext invocationContext,
            [CosmosDB(Connection = "CosmosConnectionString")] CosmosClient cosmosClient,
            ILogger logger)
        {  //.......

Expected behavior

Should bind.

Actual behavior

Does not bind.

Reproduction Steps

Not the easiest thing to reproduce given that requires an authentication service, a client app and azure configuration.

I can provide further details but I would just like to know if it is possible to bind to the UserId property.

[CosmosDB("Crib", "Players", Connection = "CosmosConnectionString", Id = "{UserId}", PartitionKey = "{UserId}")]

Environment

Azure Functions.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <AzureFunctionsVersion>v4</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="4.2.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.9.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.3" />
  </ItemGroup>

Visual Studio 17.5.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant