Properly encode URL for Webtest configuration XML with Terraform on Azure - 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:

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" />

Azure Media Service returns 0 duration with account filter

I am using Azure Media Service v3 to store and encode videos. As a trial, I'd want to show the initial 30 seconds to the User and they can see the rest if they sign up.
So to get the initial 30 seconds, I decided to use the manifest filter as described in the Azure website.
I created an account filter with the following settings and it got created successfully. However, whenever I try to play that video with the URL, I get the manifest file with duration equals to 0 and video fails to play.
Settings I used:
{
"properties": {
"presentationTimeRange": {
"startTimestamp": 0,
"endTimestamp": 300000000,
"presentationWindowDuration": 600000000,
"liveBackoffDuration": 0,
"timescale": 10000000,
"forceEndTimestamp": true
}
}
}
URL I am using to play video:
https://xxx-xxx.streaming.media.azure.net/resource-id/video-name.ism/manifest(filter=free-user)
This is how my original manifest looks:
<?xml version="1.0" encoding="UTF-8"?>
-<SmoothStreamingMedia TimeScale="10000000" Duration="4317653333" MinorVersion="2" MajorVersion="2">
-<StreamIndex Name="aac_und_2_127999_2_1" Language="und" QualityLevels="1" Url="QualityLevels({bitrate})/Fragments(aac_und_2_127999_2_1={start time})" Type="audio" Chunks="72">
<QualityLevel SamplingRate="48000" PacketSize="4" Channels="2" CodecPrivateData="1190" FourCC="AACL" Bitrate="127999" BitsPerSample="16" Index="0" AudioTag="255"/>
<c r="71" d="60160000" t="0"/>
<c d="46293333"/>
</StreamIndex>
-<StreamIndex QualityLevels="5" Url="QualityLevels({bitrate})/Fragments(video={start time})" Type="video" Chunks="72">
<QualityLevel CodecPrivateData="000000016764001FACD9405005BB011000000300100000030320F18319600000000168EBECB22C" FourCC="H264" Bitrate="762429" Index="0" MaxHeight="720" MaxWidth="1280"/>
<QualityLevel CodecPrivateData="000000016764001FACD940F0117EF011000003000100000300320F1831960000000168EBECB22C" FourCC="H264" Bitrate="456443" Index="1" MaxHeight="540" MaxWidth="960"/>
<QualityLevel CodecPrivateData="000000016764001EACD940A02FF97011000003000100000300320F162D960000000168EBECB22C" FourCC="H264" Bitrate="288193" Index="2" MaxHeight="360" MaxWidth="640"/>
<QualityLevel CodecPrivateData="0000000167640015ACD941E08FEB011000000300100000030320F162D9600000000168EBECB22C" FourCC="H264" Bitrate="157781" Index="3" MaxHeight="270" MaxWidth="480"/>
<QualityLevel CodecPrivateData="000000016764000CACD941419F9F011000000300100000030320F14299600000000168EBECB22C" FourCC="H264" Bitrate="99525" Index="4" MaxHeight="180" MaxWidth="320"/>
<c r="71" d="60000000" t="0"/>
<c d="54800000"/>
</StreamIndex>
</SmoothStreamingMedia>
Can anyone tell me what am I doing wrong here?
filter
Can you check if you actually have timestamp 0 in your manifest? The startTimestamp and endTimestamp settings select the range of actual timestamps in your manifest.
You can open the manifest here:
https://xxx-xxx.streaming.media.azure.net/resource-id/video-name.ism/manifest

Importing Data GI In web service

I have a requirement to import custom data into Acumatica using web service using web service.
I have created a custom table having 2 string field and one ntext field which will hold XML data.
Created a GI for it and exposed in web service endpoint.
The import JSON Data format is like this.
[
{
"OrderNbr": "1",
"CommandValue": "8",
"Xmldata": "<?xml version=\"1.0\" encoding=\"utf-8\"?><MLW Cmd=\"8\" TStamp=\"2018-12-21T11:38:25\" Id=\"dsgx1\" OrgId=\"157035408\" DevId=\"b9d863ca-REG-4825e4aa-566b5fc7\" RouteId=\"Resource-879-1\" StopId=\"Location230\" LocationKey=\"Location230\" StopType=\"67\"> <GPS Altitude=\"278.46383285522461\" Latitude=\"34.0487467032243\" Longitude=\"-84.673757432107507\" NoOfSat=\"7\" Speed=\"1.3679999828338623\" SatTStamp=\"2018-12-21T11:37:26\" Direction=\"0\" FixQuality=\"A\" /> <FieldData LCode=\"1\" OwnerId=\"Location230\"> <Field FId=\"89815\" Value=\"No\" /> <Field FId=\"89817\" Value=\"No\" /> <Field FId=\"89816\" Value=\"Patrick N\" /> </FieldData> <Job Id=\"Order-878-4\" Status=\"4\"> <Item Status=\"4\" Id=\"TIFTUF\" Mode=\"Manual\" /> </Job></MLW>"
}
]
I have tried in POSTMAN using basic authentication.
I am getting following error
PUT: 400 Bad request
GET: 500 Internal server error.
UPDATE: I have created a custom list page and configured it in the endpoint.
I have tested in POSTMAN and
Following are the endpoint and the JSON string used to create records
http://localhost/XYZ/(W(3))/entity/XYZ/17.200.001.001/MyResposeImport
{
"OrderNbr": {value :"b"},
"CommandValue": {value :"8"},
"Xmldata": {value :"<?xml version='1.0' encoding='utf-8'?><MLW Cmd='8' TStamp='2018-12-21T11:38:25' Id='dsgx1' OrgId='157035408' DevId='b9d863ca-REG-4825e4aa-566b5fc7' RouteId='Resource-879-1' StopId='Location230' LocationKey='Location230' StopType='67'> <GPS Altitude='278.46383285522461' Latitude='34.0487467032243' Longitude='-84.673757432107507' NoOfSat='7' Speed='1.3679999828338623' SatTStamp='2018-12-21T11:37:26' Direction='0' FixQuality='A' /> <FieldData LCode='1' OwnerId='Location230'> <Field FId='89815' Value='No' /> <Field FId='89817' Value='No' /> <Field FId='89816' Value='Patrick N' /> </FieldData> <Job Id='Order-878-4' Status='4'> <Item Status='4' Id='TIFTUF' Mode='Manual' /> </Job></MLW>"}
}
PUT Returns back OK and the response give below
{
"id": "94a00013-37bf-4077-bfb6-2e8662988547",
"rowNumber": 1,
"note": null,
"OrderNbr": {
"value": "b"
},
"ShippingStatus": {},
"XMLData": {},
"custom": {},
"files": []
}
I have checked in the back end and no record added to the table.
I have created the sitemap under the hidden section since the screen is only API call.
What may be the reason for the record not added to the table?
I have solved the Issue. The JSON Data field name is different from DAC label and API is look DAC label not the field name.
I have changed the JSON data to following and it works fine
{
"OrderNbr": {value :"b"},
"ShippingStatus": {value :"8"},
"XMLData": {value :"<?xml version='1.0' encoding='utf-8'?><MLW Cmd='8' TStamp='2018-12-21T11:38:25' Id='dsgx1' OrgId='157035408' DevId='b9d863ca-REG-4825e4aa-566b5fc7' RouteId='Resource-879-1' StopId='Location230' LocationKey='Location230' StopType='67'> <GPS Altitude='278.46383285522461' Latitude='34.0487467032243' Longitude='-84.673757432107507' NoOfSat='7' Speed='1.3679999828338623' SatTStamp='2018-12-21T11:37:26' Direction='0' FixQuality='A' /> <FieldData LCode='1' OwnerId='Location230'> <Field FId='89815' Value='No' /> <Field FId='89817' Value='No' /> <Field FId='89816' Value='Patrick N' /> </FieldData> <Job Id='Order-878-4' Status='4'> <Item Status='4' Id='TIFTUF' Mode='Manual' /> </Job></MLW>"}
}

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.

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

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)

Resources