Amazon SNS configuration for Data Pipeline success and failure - amazon

I am using the Amazon data pipeline for the automation of some shell activity. Which will run once in a day. So, I was configuring the amazon SNS for letting me know whether the last run of the shell activity was successful or fail. If, failed then email me the reason of failure.
So, I was able to configure the SNS for sending me the mail. But, how should I configure the message part of SNS so that in case of failure, it send me the exact error? Also, in case of success send me the status SUCCESS.

You can try node references to refer to the object on which the action is added http://docs.aws.amazon.com/datapipeline/latest/DeveloperGuide/dp-pipeline-expressions.html shows how to do this.

Ok this is my working Dynamo -> S3 import.
https://gist.github.com/osvadimos/2954ce4c0f7fc249594c999822e639f2
Regarding your question.
First you have to create Fail/Success Object
public static PipelineObject getSNSFailActivity() {
String name = "FailureNotify";
String id = "FailureNotify";
Field type = new Field()
.withKey("type")
.withStringValue("SnsAlarm");
Field topicArn = new Field()
.withKey("topicArn")
.withStringValue("#{myTopicFail}");
Field role = new Field()
.withKey("role")
.withStringValue("DataPipelineDefaultRole");
Field subject = new Field()
.withKey("subject")
.withStringValue("FAIL: #{node.#scheduledStartTime}");
Field message = new Field()
.withKey("message")
.withStringValue("#{myDDBTableName}");
List<Field> fieldsList = Lists.newArrayList(type,
role,
topicArn,
subject,
message);
return new PipelineObject()
.withName(name)
.withId(id)
.withFields(fieldsList);
}
You have to add reference of Fail/Success object to your S3BackupLocation object
public static PipelineObject getS3BackupLocation() {
String name = "S3BackupLocation";
String id = "S3BackupLocation";
Field type = new Field()
.withKey("type")
.withStringValue("S3DataNode");
Field directoryPath = new Field()
.withKey("directoryPath")
.withStringValue("#{myOutputS3Location}#{format(#scheduledStartTime, 'YYYY-MM-dd-HH-mm-ss')}");
Field onFail = new Field()
.withKey("onFail")
.withRefValue("FailureNotify");
Field onSuccess = new Field()
.withKey("onSuccess")
.withRefValue("SuccessNotify");
List<Field> fieldsList = Lists.newArrayList(type,
directoryPath,
onFail,
onSuccess);
return new PipelineObject()
.withName(name)
.withId(id)
.withFields(fieldsList);
}

Related

Referencing Message UserProperties from SQLFilter

I'm trying to filter messages for my Subscription Clients in Azure Service Bus. I'd like to check if the property does not exist or the property has a certain value. This is how I add the filter:
var rules = await subscriptionClient_.GetRulesAsync();
if (!rules.Any(r => r.Name == "FilteringRule"))
{
var filter = new SqlFilter($"sys.CustomProperty='{CustomValue}' OR sys.CustomProperty IS NULL");
await subscriptionClient_.AddRuleAsync("FilteringRule", filter);
}
And the same value is passed over to the Microsoft.Azure.ServiceBus.Message object:
Message msg = new Message();
msg.UserProperties.Add("CustomProperty", "CustomValue");
Checking it in Service Bus explorer displays that the message indeed has the property.
I'm trying to figure out how to filter Subscriptions programmatically, not by ARM templates.
The reason the filter is not working because you're trying to treat custom properties as system properties. Please try to change your filter expression to:
var filter = new SqlFilter($"CustomProperty='{CustomValue}' OR CustomProperty IS NULL");
and things should work. Please note that I have removed sys. prefix from your filter expression.

Exchange Service Finditems giving 407 error

we need to search email from outlook.com and to achieve this we are using Exchange Web Service (EWS) but getting 407 error a the time of calling FindItem method of service.
Here is the code which we are working on -
List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Subject, "Test"));
//searchFilterCollection.Add(new SearchFilter.ContainsSubstring(ItemSchema.Body, "homecoming"));
SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray());
ItemView view = new ItemView(50);
// Identify the properties to return in the result set and the additional properties that are returned for each item.
view.PropertySet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, ItemSchema.DateTimeReceived);
//Order the search results by the DateTimeReceived property. The sort direction is in descending order.
view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);
//Set the manner by which the search filter traverses the target folder. In the following example, the search filter performs a shallow traversal. Shallow is the default option; other traversal options are Associated and SoftDeleted.
view.Traversal = ItemTraversal.Shallow;
string userEmailAddress = "username#outlook.com";
string userPassword = "OutlookPassword";
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);
service.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
service.Credentials = new WebCredentials(userEmailAddress, userPassword);
FindItemsResults<Item> findResults = service.FindItems(WellKnownFolderName.Inbox, searchFilter, view);
Getting error at last line of code.
Can you please guide what need to be correct to resolve it?
Thank You!

Qualify Lead in MS CRM 2011

I'm newbie to CRM. I want to qualify a lead to create opportunity. I'm passing following parameters as request
CreateOpportunity
CreateAccount
CreateContact
customerid
targetentityname
targetentityid
requestname
transactioncurrencyid
statuscode
subject
fullname
lastname
companyname
createdby
campaignid
But am getting Insufficient parameter error as response.
Can anybody help me out by providing the missing parameters?
In case you need to create only opportunity from your lead it's completely enough to pass next parameters to QualifyLeadRequest:
1. CreateOpportunity
2. OpportunityCurrencyId
3. OpportunityCustomerId
4. Status
5. LeadId
Please take a look at sample code below
C#:
var rmc = new RetrieveMultipleRequest()
{
Query = new QueryExpression("organization")
{
ColumnSet = new ColumnSet("basecurrencyid")
}
};
var rmc_r = (RetrieveMultipleResponse)serviceProxy.Execute(rmc);
//Qualify lead
var qlr = new QualifyLeadRequest()
{
CreateOpportunity = true,
OpportunityCurrencyId = rmc_r.EntityCollection.Entities[0].GetAttributeValue<EntityReference>("basecurrencyid"),
OpportunityCustomerId = new EntityReference("account", new Guid(<your-existing-account-guid>)),
//3 is statuscode value "Qualified" for lead entity
Status = new OptionSetValue(3),
LeadId = new EntityReference("lead", new Guid(<your-existing-account-guid>))
};
Please take a look at SOAPLogger (SDK\SampleCode\CS\Client\SOAPLogger) tool distributed with Dynamics CRM SDK to get request XML string and send as request payload from your client extensions (JavaScript).
via

Get entity record values from Audit Details Response

Auditing of an entity is enabled,I want the entity record after deletion.So
I was trying to get that from audit entity records,like this:
RetrieveAuditDetailsRequest request = new RetrieveAuditDetailsRequest();
request.AuditId = _selectedId;
RetrieveAuditDetailsResponse response = (RetrieveAuditDetailsponse)_orgService.Execute(request);
EntityReference ObjectId = (EntityReference)response.AuditDetail.AuditRecord.Attributes["objectid"];
string ObjectName = ObjectId.LogicalName;
Guid Id = ObjectId.Id;
ColumnSet col = new ColumnSet(true);
Entity ent = _orgService.Retrieve(ObjectName,Id,col);
Its throwing an error "Expected non empty Guid".
FYI, I want this record values because I want to restore/recover record by creating it again.
Please help whats wrong with it??
You are attempting to retrieve the deleted record with this code:
string ObjectName = ObjectId.LogicalName;
Guid Id = ObjectId.Id;
ColumnSet col = new ColumnSet(true);
Entity ent = _orgService.Retrieve(ObjectName,Id,col);
This will fail with the error you are getting because no such record exists (it is deleted.) Unlike CRM 4 and earlier there are no soft deletes in 2011, once deleted it is gone from the database.
Replace it with the following code:
RetrieveRecordChangeHistoryRequest retrieveRequest = new RetrieveRecordChangeHistoryRequest();
changeRequest.Target = new EntityReference(ObjectName, Id);
RetrieveRecordChangeHistoryResponse response =
(RetrieveRecordChangeHistoryResponse)_orgService.Execute(retrieveRequest);
if (response.AuditDetailCollection != null)
{
var auditDetails = response.AuditDetailCollection;
// Do work
}
You then enumerate through the auditDetails to get the correct attributes.
You can find more at http://blogs.msdn.com/b/crm/archive/2011/05/23/recover-your-deleted-crm-data-and-recreate-them-using-crm-api.aspx.
The "Expected non empty Guid" error is thrown whenever you try to retrieve something with an empty GUID (Guid.Empty, 00000000-0000-0000-0000-000000000000). I'm guessing your _selectedId is not set to an actual GUID. Maybe you're setting it from a Nullable GUID and you are calling ValueOrDefault(), which is resulting in it getting set to the empty Guid, and failing in your Request?

Facebook Event gives error "Param eid must be a valid event id"

I am working on publish event on facebook by Facebook C# SDK. I am able to login and generate Access Token through it. But when I am publishing event I got error :
Facebook.FacebookOAuthException: (OAuthException - #100) (#100) Param eid must be a valid event id
at Facebook.FacebookClient.ProcessResponse(HttpHelper httpHelper, String responseString, Type resultType, Boolean containsEtag, IList`1 batchEtags)
at Facebook.FacebookClient.Api(HttpMethod httpMethod, String path, Object parameters, Type resultType)
at Facebook.FacebookClient.Post(String path, Object parameters)
at FacebookSDK.Facebook.CreateEvent(FBEvent fbEvent)
My code is
public void CreateEvent(FBEvent fbEvent)
{
var fb = new FacebookClient(this.AccessToken);
dynamic parameters = new ExpandoObject();
parameters.eid = "524654568165461";
parameters.owner = "me";
parameters.description = fbEvent.Description;
parameters.name = fbEvent.Title;
parameters.start_time = fbEvent.StartTime.ToString("yyyy-MM-dd hh:mm:ss");
parameters.end_time = fbEvent.EndTime.ToString("yyyy-MM-dd hh:mm:ss");
parameters.privacy = fbEvent.PrivacyInfo;
parameters.access_token = this.AccessToken;
dynamic result = fb.Post("me/event", parameters);
}
How i can resolve it....
Are you creating a new event? If so, delete this line from your code:
parameters.eid = "524654568165461";
If you are trying to edit an event, this eid is wrong.
After searching a lot I found the solution for it ....
You have to consider following link
asp.net + facebook create event
In my case i am trying to get data as dynamic but changed to JsonObject, it is working for me like,
JsonObject result = facebookClient.Post("/me/events", createEventParameters) as JsonObject;
I am using facebook sdk v 6.0.20

Resources