How to get die GET-Query-Parameter in einer einfachen Weise auf Azure-Funktionen in C#?

Versuchte ich

    ///<summary>
    ///Request the Facebook Token
    ///</summary>
    [FunctionName("SolicitaFacebookToken")]
    [Route("SolicitaToken/?fbAppID={fbAppID}&fbCode={fbCode}&fbAppSecret={fbAppSecret}")]
    public static async Task<HttpResponseMessage> SolicitaFacebookToken(
        [HttpTrigger(AuthorizationLevel.Function, methods: new string[] { "get" } )]
        HttpRequestMessage req,
        TraceWriter log,
        string fbAppID,
        string fbCode,
        string fbAppSecret
    )
    { }

Wenn ich auf die URL

http://localhost:7071/api/SolicitaFacebookToken/?fbAppID=ABC&fbCode=DEF&fbAppSecret=GHI

Aber es gibt diesen Fehler:

'SolicitaFacebookToken" kann nicht aufgerufen werden, die von Azure WebJobs SDK. Ist es fehlende Azure WebJobs SDK-Attribute?
System.InvalidOperationException : 'SolicitaFacebookToken" kann nicht aufgerufen werden, die von Azure WebJobs SDK. Ist es fehlende Azure WebJobs SDK
Attribute? bei
Microsoft.Azure.WebJobs.JobHost.Validate(IFunctionDefinition
Funktion,Object key) bei async
Microsoft.Azure.WebJobs.JobHost.CallAsync(??) bei async
Microsoft.Azure.WebJobs.Script.ScriptHost.CallAsync(String
Methode,Dictionary`2 Argumente,CancellationToken cancellationToken) bei
async
Microsoft.Azure.WebJobs.Script.WebHost.WebScriptHostManager.HandleRequestAsync(FunctionDescriptor
Funktion,HttpRequestMessage request,CancellationToken
cancellationToken) bei async
Microsoft.Azure.WebJobs.Script.Host.FunctionRequestInvoker.ProcessRequestAsync(HttpRequestMessage
request,CancellationToken cancellationToken,WebScriptHostManager
scriptHostManager,WebHookReceiverManager webHookReceiverManager) bei
async
Microsoft.Azure.WebJobs.Script.WebHost.Controllers.FunctionsController.<>c__DisplayClass3_0.b__0(??)
bei async
Microsoft.Azure.WebJobs.Extensions.Http.HttpRequestManager.ProcessRequestAsync(HttpRequestMessage
Anfrage,Func`3 processRequestHandler,CancellationToken
cancellationToken) bei async
Microsoft.Azure.WebJobs.Script.WebHost.Controller.FunctionsController.ExecuteAsync(HttpControllerContext
controllerContext,CancellationToken cancellationToken) bei async
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage
request,CancellationToken cancellationToken) bei async
System.Web.Http.Dispatcher.HttpControllerDispatcher.SendAsync(HttpRequestMessage
request,CancellationToken cancellationToken) bei async
Microsoft.Azure.WebJobs.Script.WebHost.Handler.WebScriptHostHandler.SendAsync(HttpRequestMessage
request,CancellationToken cancellationToken) bei async
Microsoft.Azure.WebJobs.Script.WebHost.Handler.SystemTraceHandler.SendAsync(HttpRequestMessage
request,CancellationToken cancellationToken) bei async
System.Web.Http.HttpServer.SendAsync(HttpRequestMessage
request,CancellationToken cancellationToken)

Wenn ich auf

HttpRequestMessage req,
        string fbAppID,
        string fbCode,
        string fbAppSecret,
        TraceWriter log

[14/04/2018 15:24:49] Die folgenden 1-Funktionen sind in Fehler:

[14/04/2018 15:24:49] SolicitaFacebookToken: Microsoft.Azure.WebJobs.Gastgeber: Fehler Indizierung Methode 'Function1.SolicitaFacebookToken'. Microsoft.Azure.WebJobs.Host: Cannot bind-parameter 'fbAppID' zum Typ String. Stellen Sie sicher, dass der parameter-Typ wird unterstützt durch die Bindung. Wenn Sie verbindlich Erweiterungen (z.B. ServiceBus, Timer, etc.) stellen Sie sicher, dass Sie angerufen haben das Anmeldeverfahren für die Erweiterung(en) in Ihrem startup-code (z.B. config.UseServiceBus(), config.UseTimers(), etc.).

In der Azure-Funktionen template-code, es ist

string name = req.GetQueryNameValuePairs()
                 .FirstOrDefault(q => string.Compare(q.Key, "name", true) == 0)
                 .Value;

Wäre ich gerne ein einfacher Weg, um der GET-query-Parameter.

Ich will eine URL wie

http://localhost:7071/api/SolicitaFacebookToken/?fbAppID=123&fbCode=456&fbAppSecret=789

und einfach die Parameter und Ihre Werte.

, Wie es zu tun?

InformationsquelleAutor Tony | 2018-04-14
Schreibe einen Kommentar