Trying to get TaskHubName from DurrableClient on .net 7 isolated azure function

102 Views Asked by At

i'm currently migrating azure function from .net core 3.1 to .net 7, use isolated process, my current code ( .net 3.1 and in-process function ) as below

> [FunctionName("ResetMyState")]
>         public async Task<HttpResponseMessage> ResetMyState(
>             [HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestMessage req,
>             [DurableClient] IDurableClient client,
>             ILogger log)
>         {
>             // Get the connection string from app settings
>             string connString = this._nameResolver.Resolve("AzureStorage");
>             var settings = new AzureStorageOrchestrationServiceSettings
>             {
>                 StorageConnectionString = connString,
>                 **TaskHubName = client.TaskHubName,**
>             };
>                       // business code here
>                       return req.CreateResponse(System.Net.HttpStatusCode.OK);        }

Is there any similar way that lets me take the TaskHubName in .net 7 isolated function ? and another thing is as I know Isolated function only support HttpRequest/ResponseData but the existing code's using HttpRequest/ResponseMessage, will it still work as expected or I need to change that as well ?

Thank you. Dan

1

There are 1 best solutions below

0
On

Is there any similar way that lets me take the TaskHubName in .net 7 isolated function ?

Yes, you can take the hubName in the host.json or local.settings.json file. Please refer ms docs for more details.

enter image description here

I am getting the results while hitting the urls given here using hubname and connection string declared in my host.json file.

enter image description here

as I know Isolated function only support HttpRequest/ResponseData but the existing code's using HttpRequest/ResponseMessage, will it still work as expected or I need to change that as well ?

Use HttpResponseData instead of HttpResponseMessage for isolated process as shown below

[Function("DurableFunctionsOrchestrationCSharp1_HttpStart")]

public  static  async  Task<HttpResponseData> HttpStart(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequestData  req,
[DurableClient] DurableTaskClient  client,
FunctionContext  executionContext)