How can I access properties from a running workflow 2013 instance using CSOM? - sharepoint

I am trying to figure out how I can access properties of a running workflow instance. I have created the following PowerShell:
Add-PSSnapin microsoft.sharepoint.powershell
$web = Get-SPWeb http://app-72b5c37f94da1d.apps.sharepoint2013.local/sites/appdev/SharePointWorkflowApp
$wfm = New-object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$list= ($web.lists|where Title -eq "List1")
$sub = $wfm.GetWorkflowSubscriptionService()
$subscriptions = $sub.EnumerateSubscriptionsByList($list.ID)
$inst = $wfm.GetWorkflowInstanceService()
$instances= $inst.Enumerate($subscriptions[0])
$instance= $instances[0]
$instance.Status
$instance.UserStatus
$instance.Properties
I am not able to retrieve the arguments or variables via this route. Only UserStatus is a valid working option at this point.
The variables and arguments of the sequence which I have configured via Visual Studio 2013's Workflow Designer, resulted in the following xaml:
<x:Members>
<x:Property Name="EenArg" Type="InArgument(x:String)" />
<x:Property Name="argument1" Type="x:String" />
<x:Property Name="argument2" Type="InOutArgument(x:String)" />
<x:Property Name="strArg" Type="InOutArgument(x:String)" />
<x:Property Name="intArg" Type="InOutArgument(x:String)" />
<x:Property Name="dateTimeArg" Type="InOutArgument(x:String)" />
</x:Members>
None of which are propagated via de Properties collection.
What am I missing here?
(crossposted at MSDN Forums as well:
http://social.msdn.microsoft.com/Forums/en-US/482412b9-86ca-435e-becb-bfbc6a33c378/how-to-access-properties-of-running-workflow-2013-instances?forum=sharepointdevelopment)

Related

appcmd.exe to list IIS config section attribute is returning an ERROR message:Unknown attribute

I am running this command as admin in elevated prompt:
%systemroot%\system32\inetsrv\appcmd list config "website" /section:requestFiltering /text:AllowDoubleEscaping
It returns error message: ERROR (message:Unknown attribute ""AllowDoubleEscaping"". Replace with -? for help.)
So I next ran the following command:
%systemroot%\system32\inetsrv\appcmd set config -section:requestFiltering -?
It returned this output and yes, I can see that the allowDoubleEscaping is missing
ERROR ( message:-allowHighBitCharacters
-unescapeQueryString
-removeServerHeader
-fileExtensions.allowUnlisted
-fileExtensions.applyToWebDAV
-fileExtensions.[fileExtension='string'].fileExtension
-fileExtensions.[fileExtension='string'].allowed
-requestLimits.maxAllowedContentLength
-requestLimits.maxUrl
-requestLimits.maxQueryString
-requestLimits.headerLimits.[header='string'].header
-requestLimits.headerLimits.[header='string'].sizeLimit
-verbs.allowUnlisted
-verbs.applyToWebDAV
-verbs.[verb='string'].verb
-verbs.[verb='string'].allowed
-hiddenSegments.applyToWebDAV
-hiddenSegments.[segment='string'].segment
-alwaysAllowedUrls.[url='string'].url
-alwaysAllowedQueryStrings.[queryString='string'].queryString
-denyUrlSequences.[sequence='string'].sequence
-denyQueryStringSequences.[sequence='string'].sequence
-filteringRules.[name='string'].name
-filteringRules.[name='string'].scanUrl
-filteringRules.[name='string'].scanQueryString
-filteringRules.[name='string'].scanAllRaw
-filteringRules.[name='string'].denyUnescapedPercent
-filteringRules.[name='string'].scanHeaders.[requestHeader='string'].requestHeader
-filteringRules.[name='string'].appliesTo.[fileExtension='string'].fileExtension
-filteringRules.[name='string'].denyStrings.[string='string'].string
So which files is appcmd actually checking for these? I went ahead and checked the C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml file and it does have this attribute defined in there. This seems to be the only place this is defined, so I am confused where else its not finding this attribute to throw the error??
<sectionSchema name="system.webServer/security/requestFiltering">
<attribute name="allowDoubleEscaping" type="bool" defaultValue="false" />
<attribute name="allowHighBitCharacters" type="bool" defaultValue="true" />
<attribute name="unescapeQueryString" type="bool" defaultValue="true" />

Properly encode URL for Webtest configuration XML with Terraform on Azure

I'm trying to setup a azurerm_application_insights_web_test with Terraform. Currently having issues with the Url parameter in the configuration WebTest XML.
I'm just not figuring out how I'd have to properly encode the string. For "simple" URLs, it's no problem. But what about eg. https://a.skwar.me/example=yes? The problem is with the "=" (equal) sign in the URL.
If I set Url="https://a.skwar.me/example=yes" in the XML, terraform apply fails:
2021-12-03T08:32:47.4173868Z Error: creating/updating Application Insights Web Test: (Name "dummy3aaiwt" / Resource Group "SharedienDevopsTesting"): insights.WebTestsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: Service returned an error. Status=400 Code="BadRequest" Message="Specified argument was out of the range of valid values.\r\nParameter name: Web test 'dummy3aaiwt' is invalid. Ensure it is a well formed XML and that it adheres to the web test schema. Technical error: '=' is an unexpected token. The expected token is ';'. Line 23, position 33." InnerError={"diagnosticcontext":"6a6fb5be-fba9-4110-be6a-beffd2a44ef1","time":"2021-12-03T08:32:47.3359710Z"}
Note: Technical error: '=' is an unexpected token. The expected token is ';'
I tried to simply urlencode() the whole URL. Apply works, but no tests are being done. If I go Azure Portal, I see that the parameter hasn't been decoded; ie. I see https%3A%2F%2Fa.skwar.me%2Fexample%3Dyes. I also cannot save the test, as the URL is invalid (… d'oh!)
I've got this:
resource "azurerm_application_insights_web_test" "dummy3" {
name = "dummy3aaiwt"
location = local.ai_this.location
resource_group_name = local.ai_this.resource_group_name
application_insights_id = local.ai_this.id
kind = "ping"
frequency = 900
timeout = 120
enabled = true
retry_enabled = true
geo_locations = split(",", local.test_locations)
configuration = <<XML
<WebTest
Name="abcdefXML"
Id="${random_uuid.dummy.result}"
Enabled="True"
CssProjectStructure=""
CssIteration=""
Timeout="120"
WorkItemIds=""
xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"
Description=""
CredentialUserName=""
CredentialPassword=""
PreAuthenticate="True"
Proxy="default"
StopOnError="False"
RecordedResultFile=""
ResultsLocale="">
<Items>
<Request
Method="GET"
Guid="${random_uuid.dummy2.result}"
Version="1.1"
Url="${urlencode("https://a.skwar.me/some-exampe?foo=bar")}"
ThinkTime="0"
Timeout="120"
ParseDependentRequests="False"
FollowRedirects="True"
RecordResult="True"
Cache="False"
ResponseTimeGoal="0"
Encoding="utf-8"
ExpectedHttpStatusCode="302"
ExpectedResponseUrl=""
ReportingName=""
IgnoreHttpStatusCode="False" />
</Items>
</WebTest>
XML
}
Using Terraform Version 1.0.11 and provider registry.terraform.io/hashicorp/azurerm v2.86.0 , if I try to use urlencode in the url parameter then I am also facing the same issue that you see in portal as below:
But directly providing the URL using the below code succeeds and URL is also correctly defined in portal and can be saved as well.
resource "azurerm_application_insights_web_test" "example" {
name = "tf-test-appinsights-webtest"
location = data.azurerm_application_insights.example.location
resource_group_name = data.azurerm_application_insights.example.resource_group_name
application_insights_id = data.azurerm_application_insights.example.id
kind = "ping"
frequency = 300
timeout = 60
enabled = true
geo_locations = ["us-ca-sjc-azr", "us-va-ash-azr"]
configuration = <<XML
<WebTest
Name="WebTest1"
Id="ABD48585-0831-40CB-9069-682EA6BB3583"
Enabled="True"
CssProjectStructure=""
CssIteration=""
Timeout="120"
WorkItemIds=""
xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"
Description=""
CredentialUserName=""
CredentialPassword=""
PreAuthenticate="True"
Proxy="default"
StopOnError="False"
RecordedResultFile=""
ResultsLocale="">
<Items>
<Request
Method="GET"
Guid="a5f10126-e4cd-570d-961c-cea43999a200"
Version="1.1"
Url="https://a.skwar.me/some-exampe?foo=bar"
ThinkTime="0"
Timeout="300"
ParseDependentRequests="False"
FollowRedirects="True"
RecordResult="True"
Cache="False"
ResponseTimeGoal="0"
Encoding="utf-8"
ExpectedHttpStatusCode="302"
ExpectedResponseUrl=""
ReportingName=""
IgnoreHttpStatusCode="False" />
</Items>
</WebTest>
XML
}
Output:

Test NG Cucumber Parallel Automation with Dynamic test tags and param

I am currently looking to run multiple test in cucumber in parallel using testng and I successfully managed to do that.
Now my requirement is rather than having multiple Test TAGS in the testNG file with different parameters take it from the maven command line. So I can do automation without editing the testNg.xml file. Is there a way to achieve it? Please find my current testng.xml configuration.
testng.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Testng Cucumber Suite" thread-count="2" parallel="tests">
<!-- In order to run test cases please copy and one test and add make sure you add relevant parameters -->
<test name="Run_Nexus_06">
<parameter name="deviceName" value="Google Nexus 6" />
<parameter name="platformVersion" value="6.0" />
<classes>
<class name="cucumber.mobile.ParallelRunner">
</class>
</classes>
</test>
<test name="Run_Google_Pixel">
<parameter name="deviceName" value="Google Pixel" />
<parameter name="platformVersion" value="7.1" />
<classes>
<class name="cucumber.mobile.ParallelRunner">
</class>
</classes>
</test>
</suite>
Runner Class :
#CucumberOptions(plugin = {"pretty", "html:target/html/", "json:target/cucumber.json", "junit:TEST-all.xml"},
features = "src/test/resources/features/SignUp.feature", glue = {"steps"}, tags = {"#Mobile"})
public class ParallelRunner extends Hook{
List<Object[]> data;
//<parameter name="deviceName" value="Google Pixel" />
// <parameter name="platformVersion" value="7.1" />
#BeforeTest
#Parameters({"deviceName","platformVersion"})
public void bb(String deviceName, String platformVersion){
Device device = new Device();
device.setDeviceName(deviceName);
device.setOsVersion(platformVersion);
DeviceFactory.setDevice(device);
System.out.println("Device" + deviceName + "Os Version" + platformVersion + " " + Thread.currentThread().getId());
}
}
I was glad that I found this post. Very useful if anyone trying to achieve the same thing. Dynamic Test ng IAlterSuiteListener
Maven command :> mvn compile test -DdeviceFlavors="Google Nexus 6","Google Pixel" -DdeviceOsFlavors="6.0","7.1" -Dsurefire.suiteXmlFiles=testng.xml

Cannot update Azure Deployment when it is using Reserved IPs

I’m trying to install a diagnostic extension via API into an existing Azure cloud service. Cloud Service has a reserved IP assigned. I’m getting “A reserved IP cannot be added, removed or changed during deployment update or upgrade.” when doing so using ChangeConfigurationBySlot. Does anyone know the trick to get this to work? Is this a miss in the API or am I doing something wrong?
Here’s a relevant code snippet:
var dep = client.Deployments.GetBySlot(resource.ServiceName, DeploymentSlot.Production);
var serviceConfig = XElement.Parse(dep.Configuration, LoadOptions.SetBaseUri);
var config = new DeploymentChangeConfigurationParameters(serviceConfig.ToString())
{
ExtendedProperties = dep.ExtendedProperties,
Mode = DeploymentChangeConfigurationMode.Auto,
TreatWarningsAsError = false,
Configuration = serviceConfig.ToString(),
ExtensionConfiguration = new ExtensionConfiguration
{
AllRoles = new List<ExtensionConfiguration.Extension>(),
NamedRoles = extensionConfig
}
};
var result = client.Deployments.ChangeConfigurationBySlot(resource.ServiceName, DeploymentSlot.Production, config);
Here is the relevant section from cloud service config
<ServiceConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" serviceName="IS.Admin.Azure" osFamily="4" osVersion="*" schemaVersion="2014-06.2.4" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="IS.Admin">
…
</Role>
<NetworkConfiguration>
<VirtualNetworkSite name="is-prod" />
<AddressAssignments>
<InstanceAddress roleName="IS.Admin">
<Subnets>
<Subnet name="Subnet-1" />
</Subnets>
</InstanceAddress>
<ReservedIPs>
<ReservedIP name="is-admin-rip" />
</ReservedIPs>
</AddressAssignments>
</NetworkConfiguration>
</ServiceConfiguration>
My update has nothing to do with changing/removing/adding Reserved IPs. Any ideas as to how to update the service config?
Try deploying to staging and doing a vip swap. The reserved ips are sticky to the slot, so it shouldn't interfere with your IPs in prod.

Editing Web Config file using Microsoft PowerShell

i want to modify my web config file using powershell . i stuck in somewhere . i want to update appsettings and also connectionsstring information at the same time when i change them in powershel
I have this code but it changes only apppsettings value when i change it here and run it but i also want to include connectionstring here. How can i achieve it ?
$webConfig = "C:\Inetpub\Wwwroot\application\web.config"
$doc = new-object System.Xml.XmlDocument
$doc.Load($webConfig)
$doc.get_DocumentElement()."appsetting".add[0].value = "true"
$doc.Save($webConfig)
Here is my web config file
<appSettings>
<add key="mykey1" value="false"/>
<add key="mykey2" value="true"/>
<add key="mykey3" value="false"/>
</appSettings>
<connectionstrings>
<add name="myname1" connectinstring="Data Source=ABDULLAH-PC\SQLEXPRESS;Initial Catalog=UserDataBase;
Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="myname2" connectinstring="myconnectionstring2" />
<add name="myname3" connectinstring="myconnectionstring3" />
</connectionStrings>
Here i want to upadate appsettings -( key and value) and also connectionstrings( name and initialcatalog)
at the same time
when i tried your code it gives me this error
Property '#text' cannot be found on this object; make sure it exists and is settable.
At line:3 char:66
+ $doc.SelectSingleNode('//appSettings/add[#key="mykey1"]/#value'). <<<< '#text' = 'false'
+ CategoryInfo : InvalidOperation: (#text:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
Property '#text' cannot be found on this object; make sure it exists and is settable.
At line:4 char:85
+ $doc.SelectSingleNode('//connectionStrings/add[#name="myname1"]/#connectionstring'). <<<< '#text'='my_string'
+ CategoryInfo : InvalidOperation: (#text:String) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound
$webConfig = "C:\Inetpub\Wwwroot\application\web.config"
$doc = (gc $webConfig) -as [xml]
$doc.SelectSingleNode('//appSettings/add[#key="mykey1"]/#value').'#text' = 'true'
$doc.SelectSingleNode('//connectionStrings/add[#name="myname1"]/#connectionstring').'#text' = 'my_string'
$doc.Save($webConfig)
You can use XPath to select your nodes and set their value via the #text property PowerShell adds.
Note - your example xml has problems with casing and some typos. Here is what I tested with:
<root>
<appSettings>
<add key="mykey1" value="false"/>
</appSettings>
<connectionStrings>
<add name="myname1" connectionstring="Data Source=ABDULLAH-PC\SQLEXPRESS;Initial Catalog=UserDataBase; Integrated Security=True" providerName="System.Data.SqlClient" />
</connectionStrings>
</root>

Resources