NamespaceManager.CreateSubscription throws MessagingEntityNotFoundException - azure

I've also set up other subscriptions and they work.
But when I'm trying to empty the queue of a subscription, the subscription no longer exists.
What I'm trying to do is make a new subscription
if (!namespaceManager.SubscriptionExists(TopicName, SubscriptionName))
{
SubscriptionDescription subscription = new SubscriptionDescription(TopicName, SubscriptionName)
{
DefaultMessageTimeToLive = TimeSpan.FromDays(1),
LockDuration = TimeSpan.FromSeconds(20),
EnableDeadLetteringOnMessageExpiration = true,
EnableDeadLetteringOnFilterEvaluationExceptions = true
};
namespaceManager.CreateSubscription(subscription);
}
The last line (CreateSubscription) throws a MessagingEntityNotFoundException.
Am I missing something?

Problem solved. Had to make a topic first.
if (!namespaceManager.TopicExists(TopicName))
{
var td = new TopicDescription(TopicName);
td.MaxSizeInMegabytes = 5120;
namespaceManager.CreateTopicAsync(td);
}

Related

Enable Azure SQL Server Auditing with Pulumi

I am trying to enable auditing on an Azure SQL server resource with a Pulumi stack. However, the setting never turns on with the script that I have. I've looked at various blogs and ARM templates for how it looks, but the blogs always mention you need to enable auditing on the master database in order to have this setting enabled. The setting I am trying to enable through Pulumi is shown below
My pulumi stack is shown here:
var dbServer = new AzureNative.Sql.Server("dbServer", new AzureNative.Sql.ServerArgs
{
ServerName = dbServerName.ToLower(),
ResourceGroupName = resourceGroupName,
AdministratorLogin = username,
AdministratorLoginPassword = password,
Version = "12.0",
MinimalTlsVersion = "1.2",
PublicNetworkAccess = AzureNative.Sql.ServerPublicNetworkAccess.Enabled,
Tags = tags,
});
var serverDiagnosticSetting = new Pulumi.AzureNative.Insights.DiagnosticSetting("serverDiagnosticSetting", new Pulumi.AzureNative.Insights.DiagnosticSettingArgs
{
Logs =
{
new Pulumi.AzureNative.Insights.Inputs.LogSettingsArgs {
Category = "SQLSecurityAuditEvents", Enabled = true, RetentionPolicy = new Pulumi.AzureNative.Insights.Inputs.RetentionPolicyArgs { Days = 0, Enabled = false, },
}
},
Name = "mydiagnosticsettings",
ResourceUri = dbServer.Id,
WorkspaceId = logAnalyticsId,
}, new CustomResourceOptions(){DependsOn = new InputList<Pulumi.Resource>(){dbServer}});
var serverBlobAuditingPolicy = new AzureNative.Sql.ServerBlobAuditingPolicy("serverBlobAuditingPolicy", new AzureNative.Sql.ServerBlobAuditingPolicyArgs
{
AuditActionsAndGroups =
{
"SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP",
"FAILED_DATABASE_AUTHENTICATION_GROUP",
"BATCH_COMPLETED_GROUP",
},
BlobAuditingPolicyName = "sqlAuditingPolicy",
ResourceGroupName = resourceGroupName,
ServerName = dbServer.Name,
State = Pulumi.AzureNative.Sql.BlobAuditingPolicyState.Enabled,
IsAzureMonitorTargetEnabled = true,
StorageAccountSubscriptionId = "00000000-0000-0000-0000-000000000000"
}, new CustomResourceOptions(){DependsOn = new InputList<Pulumi.Resource>(){dbServer}});
Running this stack, however, the setting is never enabled.
You cannot configure a diagnostic setting on the server directly.
You have to use the master database URI
var databaseMaster = dbServer.Id.Apply(id => id+"/databases/master");
var serverDiagnosticSetting = new Pulumi.AzureNative.Insights.DiagnosticSetting("serverDiagnosticSetting", new Pulumi.AzureNative.Insights.DiagnosticSettingArgs
{
Logs =
{
new Pulumi.AzureNative.Insights.Inputs.LogSettingsArgs {
Category = "SQLSecurityAuditEvents", Enabled = true, RetentionPolicy = new Pulumi.AzureNative.Insights.Inputs.RetentionPolicyArgs { Days = 0, Enabled = false, },
}
},
Name = "mydiagnosticsettings",
ResourceUri = databaseMaster,
WorkspaceId = logAnalyticsId,
}, new CustomResourceOptions(){DependsOn = new InputList<Pulumi.Resource>(){dbServer}});

How to set output contexts while creating a intent in dialogflow PHP?

I am trying to set output context to a particular intent via v2 create intent API.
Please check my code.
use Google\Cloud\Dialogflow\V2\SessionsClient;
use Google\Cloud\Dialogflow\V2\TextInput;
use Google\Cloud\Dialogflow\V2\QueryInput;
use Google\Cloud\Dialogflow\V2\IntentsClient;
use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase_Part;
use Google\Cloud\Dialogflow\V2\Intent_TrainingPhrase;
use Google\Cloud\Dialogflow\V2\Intent_Message_Text;
use Google\Cloud\Dialogflow\V2\Intent_Message;
use Google\Cloud\Dialogflow\V2\Intent;
use Google\Cloud\Dialogflow\V2\Context;
use Google\Cloud\Dialogflow\V2\ContextsClient;
private function intent_create(){
putenv('GOOGLE_APPLICATION_CREDENTIALS='.getcwd() . '/strive_stage.json');
$intentsClient = new IntentsClient();
/** Create Intent **/
$disaplayName = "Where is Goa";
$utterances = ["Goa", "Where is Goa"];
// prepare training phrases for intent
$trainingPhrases = [];
foreach ($utterances as $trainingPhrasePart) {
$part = new Intent_TrainingPhrase_Part();
$part->setText($trainingPhrasePart);
// create new training phrase for each provided part
$trainingPhrase = new Intent_TrainingPhrase();
$trainingPhrase->setParts([$part]);
$trainingPhrases[] = $trainingPhrase;
}
$messageTexts = 'Goa is in India.';
// prepare messages for intent
$text = new Intent_Message_Text();
$text->setText([$messageTexts]);
$message = new Intent_Message();
$message->setText($text);
$createIntentObject = $intentsClient->projectAgentName(env("DIALOG_FLOW_PROJECT_ID"));
// prepare intent
$intent = new Intent();
$intent->setDisplayName($disaplayName);
$intent->setTrainingPhrases($trainingPhrases);
$intent->setMessages([$message]);
$contexts = ['test'];
foreach($contexts as $con){
$contextObj = new Context();
$contextObj->setName($con);
$contextData[] = $contextObj;
$intent->setOutputContexts($contextData);
}
// $intent->getOutputContexts('test');
//dd($intent);
$response = $intentsClient->createIntent($createIntentObject, $intent);
printf('Intent created: %s' . PHP_EOL, $response->getName());
}
I am getting error message
{
"message": "com.google.apps.framework.request.BadRequestException: Resource name does not match format 'projects/{project_id}/agent/sessions/{session_id}/contexts/{context_id}' or 'projects/{project_id}/locations/{location_id}/agent/sessions/{session_id}/contexts/{context_id}'.",
"code": 3,
"status": "INVALID_ARGUMENT",
"details": []
}
I believe the issue is with the format of storing the output context. Please help me on this.
I had the same issue. The answer is to not put in the bare name, but to have a string of a certain format made
see http://googleapis.github.io/google-cloud-php/#/docs/google-cloud/v0.131.0/dialogflow/v2/intent?method=setOutputContexts
// $projectId your project id
// $sessionId can be anything, I use $sessionId = uniqid();
$uri = "projects/$projectId/agent/sessions/$sessionId/contexts/$con";
$contextObj->setName($uri);
I can see that there are any response about this topic.
I leave here my solution for the next generations
To create a output context you need to create the correct format, for this objetive you can use Context class Google\Cloud\Dialogflow\V2\Context
private function parseoOutputContexts($contexts, $project_id, $lifespan = 5)
{
$newContexts = array();
foreach ($contexts as $context) {
$newContexts[] = new Context(
[
'name' => 'projects/' . $project_id . '/agent/sessions/-/contexts/' . $context,
'lifespan_count' => $lifespan
]
);
}
return $newContexts;
}
And you can use this function to finnaly add the output context to the object Intent.
$dialogflow_intent = new Intent();
$output_contexts = ['output_context_1'. 'output_context_2'];
$output_contexts = $this->parseOutputContexts($output_contexts, '[YOUR_PROJECT_ID]');
$dialogflow_intent->setOutputContexts($output_contexts);

How do I update NetSuite Department isInactive via WSDL?

I'm trying to update NetSuite Department via WSDL but I'm having an issue updating isInactive. Below is my code in C#:
var record = new com.netsuite.webservices.Department
{
internalId = dp.InternalId,
isInactive = dp.InActive
};
then called
var result = ServiceClient.update(record);
The Department's DEPARTMENT IS INACTIVE on NetSuite doesn't check whether I set it to true or false. What am I doing wrong here?
You forgot to set isInactiveSpecified
Try this:
var record = new com.netsuite.webservices.Department
{
internalId = dp.InternalId,
isInactive = dp.InActive,
isInactiveSpecified = true
};
You need to first .get() the record, set some properties, then .update() the record. Here's what works for me:
var ns = new NetSuite.NetSuiteService();
// passport info skipped
var departmentRef = new RecordRef
{
internalId = "1",
type = RecordType.department,
typeSpecified = true
};
var response = ns.get(departmentRef);
var department = response.record as Department;
department.isInactive = true;
ns.update(department);

Acumatica get Sales Order by Customer Order field

I am attempting to retrieve a single sales order based on the Customer Order field in Acumatica with the Contract Based API. See my code below, which I based off of code in the Contract Based Documentation (page 82).
public SalesOrder GetSalesOrder(string orderNumber)
{
var binding = new System.ServiceModel.BasicHttpBinding()
{
AllowCookies = true,
MaxReceivedMessageSize = 655360,
MaxBufferSize = 655360,
SendTimeout = new TimeSpan(0, 2, 0)
};
var soToBeFound = new SalesOrder()
{
OrderType = new StringValue { Value = "SO" },
CustomerOrder = new StringValue { Value = orderNumber }
};
var address = new System.ServiceModel.EndpointAddress(ConfigurationManager.AppSettings["AcumaticaUrl"]);
using (DefaultSoapClient client = new DefaultSoapClient(binding, address))
{
client.Login(_acumaticaUid, _acumaticaPwd, _acumaticaCompany, null, null);
var existingOrder = (SalesOrder)client.Get(soToBeFound);
client.Logout();
return existingOrder;
}
}
When I execute this code I get this exception:
The request channel timed out while waiting for a reply after
00:01:59.9880722. Increase the timeout value passed to the call to
Request or increase the SendTimeout value on the Binding. The time
allotted to this operation may have been a portion of a longer
timeout."
As you can see, I've already increased the timeout to 2 minutes, which seems like forever. Is the Acumatica API really just this slow? Or am I doing something wrong in code?
EDIT:
When I try to get by the "OrderNbr" field instead of "CustomerOrder" field, it works perfectly. Is getting by "CustomerOrder" not allowed in this way? If not, how can I use "CustomerOrder" in a get request?
When you do search via the Contract-Based API, it's required to assign instance of the [FieldType]Search type instead of [FieldType]Value to all fields used in search criteria (StringSearch must be used instead of StringValue in your case):
var soToBeFound = new SalesOrder()
{
OrderType = new StringSearch { Value = "SO" },
CustomerOrder = new StringSearch { Value = orderNumber }
};
Just to confirm, StringSearch is also used in the sample on page 82 from the Contract Based documentation.

CRM 2013 to update statecode of Incident Resolution Entity

I am quite new to this part of CRM. I want to set the StateCode field of Incident Resolution Entity.
I am trying the following way -
IncidentResolution res = new IncidentResolution();
res.IncidentId = new EntityReference();
res.IncidentId.LogicalName =Incident.EntityLogicalName;
res.IncidentId.Id = new Guid(row["id"].ToString());
res.StateCode = new OptionSetValue((int)IncidentResolutionState.Completed)); //This Following gives the error as System.Nullable<IncidentResolution.StateCode> cannot be assigned to--It is readonly.
CloseIncidentRequest req = new CloseIncidentRequest();
req.IncidentResolution = res;
req.Status = new OptionSetValue();
req.Status.Value = 5; // Problem Solved
service.execute(req);
The problem i am facing is to set the StateCode property for Incident Resolution Entity.
Any help would be appreciated.
Thanks in Advance
you don't need to set the StateCode of the IncidentResolution, only the Status of CloseIncidentRequest:
IncidentResolution res = new IncidentResolution
{
Subject = "Resolved Sample Incident",
IncidentId = new EntityReference(Incident.EntityLogicalName, new Guid(row["id"].ToString()))
};
// Close the incident with the resolution.
CloseIncidentRequest req = new CloseIncidentRequest
{
IncidentResolution = res,
Status = new OptionSetValue(5)
};
service.execute(req);

Resources