I am trying to migrate my CSP code from PHP with Rest API to C# .NET using the SDK, but I can't seem to make any sample work.
Right now I am using Azure Functions to deploy the code, and while debugging it locally, I have a constant error of:
error CS0103: The name 'PartnerCredentials' does not exist in the current context
The sample I am trying to make work right now is:
using System;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using Microsoft.Store.PartnerCenter;
using System.Linq;
using System.Threading.Tasks;
namespace cspTest
{
public static class cspTest
{
[FunctionName("cspTest")]
public static void Run([TimerTrigger("0 */1 * * * *")] TimerInfo myTimer, ILogger log)
{
IPartnerCredentials partnerCredentials =
PartnerCredentials.Instance.GenerateByApplicationCredentials(secret, secret,login.microsoftonline.com");
// Create operations instance with partnerCredentials.
return PartnerService.Instance.CreatePartnerOperations(partnerCredentials);
}
}
}
Any help is appreciated, this is my first time working both with AZ and .NET/C# so I'm not sure if I'm missing something really obvious or if I am doing a really stupid mistake.
CodePudding user response:
error CS0103: The name 'PartnerCredentials' does not exist in the current context
- The error clearly says that , the name
PartnerCredentials
does not exist in the current context - An attempt was made to use a name that does not exist in the class, namespace, or scope.
- Verify that the name you're trying to use is available in your using directives and assembly references.
- As you are migrating the code, check if there exists any class file which you have missed to create
- Add the nuget package '
Microsoft.Store.PartnerCenter.Extensions
and include it in the using namespace
CodePudding user response:
Answer provided by @Fildor in the comments:
You need to have using Microsoft.Store.PartnerCenter.Extensions; : PartnerCredentials Class