Internal cache lookup and store value not working - azure-api-management

I am using Azure APIM Developer tier. I am trying to store a value in internal cache but it is not working.
Error message: No appropriate cache found for provided policy configuration. Policy execution will be skipped.
I understand that internal cache is available by default in APIM Developer tier. Does this message mean that it is not configured properly or there can be some other issue?
Policy (showing on cache related policies)
<!-- Check if partner info has already been cached for this subscription key and fetch it into a variable. -->
<cache-lookup-value key="#((string)context.Variables["subscriptionKey"])" variable-name="partnerInfo" caching-type="internal"/>
:
:
<set-variable name="partnerInfo" value="#{
var partnerAccountNumber = context.Variables["partnerAccountNumber"];
var partnerRegion = context.Variables["partnerRegion"];
var partnerType = context.Variables["partnerType"];
return $"{partnerAccountNumber}:{partnerRegion}:{partnerType}";
}"/>
<cache-store-value caching-type="internal" key="#((string)context.Variables["id"])" value="#((string)context.Variables["partnerInfo"])" duration="10000"/>
Trace
{
"source": "cache-lookup-value",
"timestamp": "2022-03-10T21:58:24.6068604Z",
"elapsed": "00:00:00.0005265",
"data": "No appropriate cache found for provided policy configuration. Policy execution will be skipped."
},
{
"source": "cache-lookup-value",
"timestamp": "2022-03-10T21:58:24.6068650Z",
"elapsed": "00:00:00.0005312",
"data": {
"message": "Cache lookup resulted in a miss, variable will not be set.",
"key": "2_7c486765553047aca4f1088c0e5b1b8e",
"variableName": "partnerInfo"
}
}
:
:
:
{
"source": "set-variable",
"timestamp": "2022-03-10T21:58:25.2051048Z",
"elapsed": "00:00:00.5987711",
"data": {
"message": "Context variable was successfully set.",
"name": "partnerInfo",
"value": "674756756:EMEA:CUSTOMER"
}
},
{
"source": "cache-store-value",
"timestamp": "2022-03-10T21:58:25.2051357Z",
"elapsed": "00:00:00.5988023",
"data": "No appropriate cache found for provided policy configuration. Policy execution will be skipped."
}

I just remembered that we're using self-hosted gateways. As per documentation, built-in caching is not available for this type of setup and one should use external caching mechanism.

Related

NotAuthorizedOrNotFound when pushing custom metric

When I try to push a custom metric to the Oracle Cloud Monitoring service using the Oracle Cloud CLI, I receive the following error:
ServiceError:
{
"code": "NotAuthorizedOrNotFound",
"message": "Authorization failed or requested resource not found.",
"opc-request-id": "request id",
"status": 404
}
This occurs when using the Administrator account and when using an instance principal which has monitoring permission.
Here is the JSON that I am pushing to the Monitoring service:
[
{
"namespace": "myFirstNamespace",
"compartmentId": "tenant id",
"resourceGroup": "myFirstResourceGroup",
"name": "successRate",
"dimensions": {
"resourceId": "ocid1.exampleresource.region1.phx.exampleuniqueID",
"appName": "myAppA"
},
"metadata": {
"unit": "percent",
"displayName": "MyAppA Success Rate"
},
"datapoints": [
{
"timestamp": "2021-06-01T22:19:20Z",
"value": 83.0
}
]
}
]
The CLI command that I am using is:
oci monitoring metric-data post --metric-data file://metric-data.json
The OCI CLI command should be:
oci monitoring metric-data post --metric-data file://metric-data.json --endpoint https://telemetry-ingestion.{{ region }}.oraclecloud.com
replacing {{ region }} with your region.
The --endpoint https://telemetry-ingestion.{{ region }}.oraclecloud.com parameter needs to be added.
Looks like some authorization issue. Please cross check if the instance principle has all the required permission assigned. Please review this document Publishing Custom Metrics and Overview of Monitoring

Adding requests on aws-api-gateway to aws-sqs through an integration, failures even though "version" is specified

I've an AWS Api-Gateway resource that I tried configuring to add a message to AWS-SQS, however when I try sending a request to the api I get a response:
{
"Error": {
"Code": "MissingParameter",
"Message": "Version is missing.",
"Type": "Sender"
},
"RequestId": "the-multicharacter-request-id-blah-blah"
}
I have linked the two services in the integration taband the permissions policy is the below:
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sqs:*"
],
"Effect": "Allow",
"Resource": "*"
}
]
}
I've tried adding in api-gateway permissions to the policy, adding a Version parameter in the header, starting the setup from scratch again.
Is there something I'm missing?
'Version' here specifies which version of 'SQS' service to use and should be specified as a query parameter and not the header e.g.:
?Version='2019-05-09'
'Version' specified in the policy refers to the version of the policy language.
This was a case of RTFM.
I ran into this due to a different root cause: make sure the "Action Type" is set to "Use path override" if you don't intent to use "action override"

How to Move/Rename a file in TFS Source Control 2015, using the REST API?

I am trying to move files on our internal TFS using Python and the TFS REST API; the server appears to only support the API up-to version 2, but on MSDN I cannot find any docs for versions below v4.1.
The URL I'm posting to is https://<server>/tfs/<Collection>/<Project>/_apis/tfvc/changesets
Currently my best guess at the correct JSON body for the post request looks like this:
{
"comment": "moved file",
"changes": [{
"changeType": "rename",
"item": {
"path": "<filepath>",
"version": 468,
"sourceServerItem": "<filepath>"
}
}]
}
But i cannot get further than an HTTp error 400 bad request with the following message
{
"$id": "1",
"innerException": null,
"message": "Exactly one value for PathActions is required.\r\nParameter name: change.SourceServerItem",
"typeName": "System.ArgumentException, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
"typeKey": "ArgumentException",
"errorCode": 0,
"eventId": 0
}
And for the life of me i cannot find any reference to PathActions on google, that is not for git instead of tfvc, or a correct way of providing a value for this item.
Does anybody have a way of renaming/moving files on a TFVC via a HTTP request?
It just occurred to me to do a rename using the TFS web interface and peek at the request sent by the browser.
Turns out this is the correct format:
{
"comment": "Moved File",
"changes": [
{
"changeType": 8,
"sourceServerItem": "<old path>",
"item": {
"path": "<new path>",
"version": 470
}
}
]
}

Creating schemaExtension via graph explorer failing

I tried the below query to add a schemaExtension, but it failed with an Authorization_RequestDenied response.
url: https://graph.microsoft.com/v1.0/schemaExtensions/
post data:
{
"id": "voctestextension",
"description": "voc test extension",
"targetTypes": ["User"],
"properties": [
{
"name": "trainings",
"type": "Integer"
},
{
"name": "incidents",
"type": "String"
}
]
}
Response
{
"error": {
"code": "Authorization_RequestDenied",
"message": "Insufficient privileges to complete the operation.",
"innerError": {
"request-id": "1d4d625d-99bc-46fc-9e7a-ac30d0840219",
"date": "2018-03-14T13:17:45"
}
}
}
I have given the following permissions:
In the JSON you're POSTing to Graph, can you try setting the owner property? It should be an application id of an app that you've registered.
From the documentation page for creating schema extensions:
The appId of the application that is the owner of the
schema extension. This property can be supplied on creation, to set
the owner. If not supplied, then the calling application's appId will
be set as the owner. So, for example, if creating a new schema
extension definition using Graph Explorer, you must supply the owner
property. Once set, this property is read-only and cannot be changed.

How to set the application log in an Azure webapp using Azure resource manager

Does anyone know how to set the below diagnostic settings on an Azure Web App using Azure Resource Manager (Powershell or JSON).
Using .json I can only find these settings
"requestTracingEnabled": true, /* Failed request tracing, aka 'freb' */
"httpLoggingEnabled": true, /* IIS logs (aka Web server logging) */
"logsDirectorySizeLimit": 40, /* 40 MB limit for IIS logs */
"detailedErrorLoggingEnabled": true, /* Detailed error messages */
Which turns on web server logging to filesystem but NOT Application Logging or to blob storage.
With Powershell this command only seems to work with ASM as it does not find Non-classic storage accounts given to it
Enable-AzureWebsiteApplicationDiagnostic
Any help would be appreciated. We are currently using Azure Powershell 0.9.8
Regards
The Azure Resource Manager (ARM) template json section for configuring Application Log (Blob) and Web Server Logging (Storage) based on your screenshot above is as shown below:
{
"apiVersion": "2015-08-01",
"name": "logs",
"type": "config",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', parameters('siteName'))]"
],
"properties": {
"applicationLogs": {
"azureBlobStorage": {
"level": "Information",
"sasUrl": "<Your Azure Blob Storage Account SAS Url>",
"retentionInDays": null
}
},
"httpLogs": {
"azureBlobStorage": {
"sasUrl": "<Your Azure Blob Storage Account SAS Url>",
"retentionInDays": null,
"enabled": true
}
},
"failedRequestsTracing": {
"enabled": true
},
"detailedErrorMessages": {
"enabled": true
}
}
}
References: AzureWebsitesSamples/ARMTemplates/WebAppManyFeatures.json
Hope this answer your question and help solving your issue.
Please let me know if you need further help or clarifications.
If you browse an existing webapp in Resource Explorer you'll find a config/logs section that looks something like this:
{
"id": "/subscriptions/.../config/logs",
"name": "logs",
"type": "Microsoft.Web/sites/config",
"location": "North Central US",
"properties": {
"applicationLogs": {
"fileSystem": {
"level": "Off"
},
"azureBlobStorage": {
"level": "Information",
"sasUrl": "...",
"retentionInDays": 14
}
},
...
}
I believe you can use this format in your json template to configure the logging. (This section would be a sibling to the config/web section which contains the settings mentioned in the question.)
Note though that the config/logs section is not described in the System.Web schema, and so I'd imagine is not currently supported by MS at this time. I'm pretty sure I've tried it and seen it work though.
I didn't find how to set it in the template at the first provision. But it turned out to be easy after resources were provisioned. Please see answer at https://stackoverflow.com/a/51617949/511144 for the actual script to do it that uses Set-AzureRmResource