CreateJob for Azure Data Lake Analytics from C# - c#

I am trying to create a Job using the C# api and the DataLakeAnalyticsJobManagementClient and have been unsuccessful in every attempt with the error message: "Invalid job definition.". There is no other useful information about what is invalid about it. The job is a U-SQL job and I began bey creating it in the azure portal and that worked just fine and ran correctly with no errors.
I am building up the JobInformation and JobProperties using the same information that the portal test one used and I know the U-SQL statements are valid.
JobProperties props = new JobProperties(File.ReadAllText(#"C:\myusqlscript.usql"));
var myId = Guid.NewGuid();
JobInformation jobNfo = new JobInformation("mysamplejob", JobType.USql, props,myId) { DegreeOfParallelism = 1, Priority = 1000};
jobNfo.Validate(); //<--this doesn't throw an exception either
var jobs = await _adlaJobClient.Job.ListAsync("myanalyticsaccountname");
var adlaJob = await _adlaJobClient.Job.CreateAsync("myanalyticsaccountname", myId, jobNfo);
I have tried various combinations of constructors and property settings including just using defaults for some of the properties and I get the same result: "Invalid job definition." There is no other info that would indicate missing information or formatting issues or anything like that.
Anyone out there created Azure Data Lake Analytics jobs with the C# API?

Anyone out there created Azure Data Lake Analytics jobs with the C# API?
You need to use USqlJobProperties instead of JobProperties.
var props = new USqlJobProperties(File.ReadAllText(#"C:\myusqlscript.usql"));
The official document for Data Lake analytics get started .NET SDK is not available. But we can also get some useful sample code from the histories of this document.
public static Guid SubmitJobByPath(string scriptPath, string jobName)
{
var script = File.ReadAllText(scriptPath);
var jobId = Guid.NewGuid();
var properties = new USqlJobProperties(script);
var parameters = new JobInformation(jobName, JobType.USql, properties, priority: 1, degreeOfParallelism: 1, jobId: jobId);
var jobInfo = _adlaJobClient.Job.Create(_adlaAccountName, jobId, parameters);
return jobId;
}

Related

CRM - SuppressDuplicateDetection for custom entity

My mvc application is updating the status on a custom entity in CRM dynamics 2015. we have a plugin which gets triggered when we update a specific status. We are facing a concurrency issue here, when two different is trying to update the same status at a same time on the entity, the status gets updated twice and system fires the plugin twice.
I tried using in my MVC code but it gives an error. Seems like i cannot use it on custom entity
Portal.abcclaim obj= new Portal.abcclaim ();
obj.Attributes["abcclaimreceiveddate"] = Convert.ToDateTime(DateTime.Now);
obj.Attributes["abcdateclaimsubmitted"] = Convert.ToDateTime(DateTime.Now);
obj.Attributes["abcmodifiedbycontact"] = new EntityReference(Portal.Contact.EntityLogicalName, loggedInId);
obj.Attributes["abcstatus"] = new EntityReference(Portal.abc_status.EntityLogicalName, status);
obj.Attributes["SuppressDuplicateDetection"] = false;
obj.Id = objid;
serviceProxy.Update(obj);
is there any other way to handle this?
You should use dedicated request if you want to set request parameters. In yours case it will be UpdateRequest (https://learn.microsoft.com/en-us/dotnet/api/microsoft.xrm.sdk.messages.updaterequest?view=dynamics-general-ce-9).
var updateRequest = new UpdateRequest()
{
Target = obj,
};
updateRequest["SuppressDuplicateDetection"] = false;
var response = (UpdateResponse)osvc.Execute(updateRequest);
But it doesn't look like duplicate detection will solve concurrency problems. You should check check how to use ConcurrencyBehavior parameter. You can read more about concurrency in Dynamics 365 in this MS docs article: https://learn.microsoft.com/en-us/powerapps/developer/common-data-service/optimistic-concurrency
Hope that helps.

Cannot update read/write attributes of UserPoolClient via C# SDK

When programmatically creating a Cognito user pool and app client, if the app client is to have read/write access to attributes of the user pool, that access must be explicitly given. I have been able to do so successfully for custom attributes but built-in attributes always return an error of "Invalid write attributes specified while creating a client" or "Invalid read attributes specified while creating a client".
Documentation is ... both voluminous and difficult to find. I have yet to see an example of this or an actual bit of useful documentation on the CreateUserPoolClientRequest type that says anything about this other than things like "ReadAttributes is a list of strings that are the attributes that can be read".
Here is the code I'm using that always ends up with that error message and failure to create the app client. _client is an AmazonCognitoIdentityProviderClient properly instantiated and credentialed and running in a lambda function.
var request = new CreateUserPoolClientRequest { UserPoolId = userPoolId, ClientName = $"{name}AppClient" };
var builtInAttributes = new List<string>()
{
"address","birthdate","email","family name","gender","given name","locale","middle name","name","nickname","phone number", "picture","preferred username","profile","zoneinfo","updated at","website"
};
var readAttributes = new List<string>();
var writeAttributes = new List<string>();
readAttributes.InsertRange(0,builtInAttributes);
writeAttributes.InsertRange(0, builtInAttributes);
var attributeConfig = ConfigurationHelper.GetListFromSection("UserPoolCustomAttributes");
foreach (var attribute in attributeConfig)
{
readAttributes.Add($"custom:{attribute.Key}");
writeAttributes.Add($"custom:{attribute.Key}");
}
request.ReadAttributes = readAttributes;
request.WriteAttributes = writeAttributes;
var result = await _client.CreateUserPoolClientAsync(request, CancellationToken.None);
Any help is greatly appreciated.
Figured it out. Though I have yet to find it documented anywhere, default attributes with a space in the name in the ui need to have that space replaced with an underscore when using their name in the api.

How to get all installations when using Azure Notification Hubs installation model?

Using NotificationHubClient I can get all registered devices using GetAllRegistrationsAsync(). But if I do not use the registration model but the installation model instead, how can I get all installations? There are methods to retrieve a specific installation but none to get everything.
You're correct, as of July 2016 there's no way to get all installations for a hub. In the future, the product team is planning to add this feature to the installations model, but it will work in a different way. Instead of making it a runtime operation, you'll provide your storage connection string and you'll get a blob with everything associated with the hub.
Sorry for visiting an old thread... but in theory you could use the GetAllRegistrationsAsyc to get all the installations. I guess this will return everything without an installation id as well, but you could just ignore those if you choose.
Could look something like this
var allRegistrations = await _hub.GetAllRegistrationsAsync(0);
var continuationToken = allRegistrations.ContinuationToken;
var registrationDescriptionsList = new List<RegistrationDescription>(allRegistrations);
while (!string.IsNullOrWhiteSpace(continuationToken))
{
var otherRegistrations = await _hub.GetAllRegistrationsAsync(continuationToken, 0);
registrationDescriptionsList.AddRange(otherRegistrations);
continuationToken = otherRegistrations.ContinuationToken;
}
// Put into DeviceInstallation object
var deviceInstallationList = new List<DeviceInstallation>();
foreach (var registration in registrationDescriptionsList)
{
var deviceInstallation = new DeviceInstallation();
var tags = registration.Tags;
foreach(var tag in tags)
{
if (tag.Contains("InstallationId:"))
{
deviceInstallation.InstallationId = new Guid(tag.Substring(tag.IndexOf(":")+1));
}
}
deviceInstallation.PushHandle = registration.PnsHandle;
deviceInstallation.Tags = new List<string>(registration.Tags);
deviceInstallationList.Add(deviceInstallation);
}
I am not suggesting this to be the cleanest chunk of code written, but it does the trick for us. We only use this for debugging type purposes anyways

NetSuite custom record search through suiteTalk using C#

We are having an issue with searching a custom record through SuiteTalk. Below is a sample of what we are calling. The issue we are having is in trying to set up the search using the internalId of the record. The issue here lies in in our initial development account the internal id of this custom record is 482 but when we deployed it through the our bundle the record was assigned with the internal Id of 314. It would stand to reason that this internal id is not static in a site per site install so we wondered what property to set up to reference the custom record. When we made the record we assigned its “scriptId’ to be 'customrecord_myCustomRecord' but through suitetalk we do not have a “scriptId”. What is the best way for us to allow for this code to work in all environments and not a specific one? And if so, could you give an example of how it might be used.
Code (C#) that we are attempting to make the call from. We are using the 2013.2 endpoints at this time.
private SearchResult NetSuite_getPackageContentsCustomRecord(string sParentRef)
{
List<object> PackageSearchResults = new List<object>();
CustomRecord custRec = new CustomRecord();
CustomRecordSearch customRecordSearch = new CustomRecordSearch();
SearchMultiSelectCustomField searchFilter1 = new SearchMultiSelectCustomField();
searchFilter1.internalId = "customrecord_myCustomRecord_sublist";
searchFilter1.#operator = SearchMultiSelectFieldOperator.anyOf;
searchFilter1.operatorSpecified = true;
ListOrRecordRef lRecordRef = new ListOrRecordRef();
lRecordRef.internalId = sParentRef;
searchFilter1.searchValue = new ListOrRecordRef[] { lRecordRef };
CustomRecordSearchBasic customRecordBasic = new CustomRecordSearchBasic();
customRecordBasic.recType = new RecordRef();
customRecordBasic.recType.internalId = "314"; // "482"; //THIS LINE IS GIVING US THE TROUBLE
//customRecordBasic.recType.name = "customrecord_myCustomRecord";
customRecordBasic.customFieldList = new SearchCustomField[] { searchFilter1 };
customRecordSearch.basic = customRecordBasic;
// Search for the customer entity
SearchResult results = _service.search(customRecordSearch);
return results;
}
I searched all over for a solution to avoid hardcoding internalId's. Even NetSuite support failed to give me a solution. Finally I stumbled upon a solution in NetSuite's knowledgebase, getCustomizationId.
This returns the internalId, scriptId and name for all customRecord's (or customRecordType's in NetSuite terms! Which is what made it hard to find.)
public string GetCustomizationId(string scriptId)
{
// Perform getCustomizationId on custom record type
CustomizationType ct = new CustomizationType();
ct.getCustomizationTypeSpecified = true;
ct.getCustomizationType = GetCustomizationType.customRecordType;
// Retrieve active custom record type IDs. The includeInactives param is set to false.
GetCustomizationIdResult getCustIdResult = _service.getCustomizationId(ct, false);
foreach (var customizationRef in getCustIdResult.customizationRefList)
{
if (customizationRef.scriptId == scriptId) return customizationRef.internalId;
}
return null;
}
you can make the internalid as an external property so that you can change it according to environment.
The internalId will be changed only when you install first time into an environment. when you deploy it into that environment, the internalid will not change with the future deployments unless you choose Add/Rename option during deployment.

How to get all the users in Zendesk

I have created users using CreateOrUpdateUser() method but i was unable to fetch all the users from zendesk. I am getting null for "oListUser" also I tried to fetch user list for Organization but for that also i am getting null.Any help would be appreciated. There is no issue with the connection.
Code:
ZenDeskApi.ZenDeskApi oZen = new ZenDeskApi.ZenDeskApi("https://waresolution.zendesk.com", "j#se.com", "87ggh76IO");
List<User> oListUser = oZen.GetUsers();
User oUsers = new ZenDeskApi.Model.User();
oUsers.Email = "r#se.com";
oUsers.IsVerified = true;
oUsers.Name = "R r";
oUsers..........// Other properties
int a = oZen.CreateOrUpdateUser(oUsers);
List<Organization> oOrg = oZen.GetOgranizations();
foreach (var orgItem in oOrg)
{
int orgId = orgItem.Id;
}
Take a look at this zendesk api client for C#.net on Github. See the JUSTEAT blog for more details. You can use this client to get all users like this:
Create a client:
IZendeskClient client = new ZendeskClient(
new Uri("my-zendesk-api-host-endpoint"),
"my-zendesk-username",
"my-zendesk-token"
);
Then you can use the Search resource to search all users:
var result = client.Search.Find(new ZendeskQuery<User>().WithCustomFilter("y", "x"));
You can download the code as a Nuget here
I am using ZendeskApi_v2 and I am able to get all the users using api as follows:
var userList = api.Users.GetAllUsers();
Here userList is GroupUserReponse.I doubt whether we have any method GetUsers().Atleast its not available in the version which I am using.Once you get the response you can iterate through it.
I see that this question is related to ZenDeskApi which is available at this location:
https://github.com/eneifert/ZenDeskApi.
Sorry,I have not worked on it and tried this.
Not sure if you got a response to this but for anyone else looking for info on the API:
Try instead of:
ZenDeskApi.ZenDeskApi oZen = new ZenDeskApi.ZenDeskApi("https://waresolution.zendesk.com", "j#se.com", "87ggh76IO");
ZenDeskApi.ZenDeskApi oZen = new ZenDeskApi("https://waresolution.zendesk.com", "j#se.com", "87ggh76IO");
Also, to get a paginated list of 100 users instead of the group response, just call:
var zendeskUsers = oZen.Users.GetAllUsers().Users;

Categories

Resources