What can I do if I have more than one function? For example, if I have two or more different functions, is it possible to write the entire code in one class or is it better to create one class for each function in Visual Studio Code?
I get error messages if I want to add a second function in the same class. Is it not possible to add a second function in this class?
namespace My.Functions { public static class NewFunction { [FunctionName("NewFunction")] public static async Task<dynamic> MakeApiCall( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, ILogger log) { /* Create the function execution's context through the request */ var context = await FunctionContext<dynamic>.Create(req); var args = context.FunctionArgument; var desireddisplayname = args["NewDisplayname"]; /* Create the request object through the SDK models */ var request = new UpdateUserTitleDisplayNameRequest(); request.PlayFabId = context.CallerEntityProfile.Lineage.MasterPlayerAccountId; request.DisplayName = desireddisplayname; /* Use the ApiSettings and AuthenticationContext provided to the function as context for making API calls. */ var adminApi = new PlayFabAdminInstanceAPI(context.ApiSettings, context.AuthenticationContext); /* The PlayFabServerAPI SDK methods provide means of making HTTP request to the PlayFab Main Server without any * extra code needed to issue the HTTP requests. */ return await adminApi.UpdateUserTitleDisplayNameAsync(request); } [FunctionName("ForgotPassword")] public static async Task<dynamic> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log) { log.LogInformation($"{nameof(ForgotPassword)} C# HTTP trigger function processed a request."); //... return await adminAPI.ResetPasswordAsync(new PlayFab.AdminModels.ResetPasswordRequest() { Password = newPassword, Token = tokenId }); } } }
The name 'ForgotPassword' does not exist in the current context [Newfunctions]
In addition, what is the difference between these two code blocks?
public static async Task<dynamic> MakeApiCall( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequestMessage req, ILogger log)
and
public static async Task<dynamic> Run([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req, ILogger log)
Which code block should I use?