How can I view logs from Azure REST API requests? - azure

Assume I send a request to the Azure REST API:
az rest
--method GET
--uri 'https://graph.microsoft.com/v1.0/applications/000000-00000-00000-00000'
| ConvertFrom-Json
If a request fail I get an error message:
{
"error":
{
"code": "Request_BadRequest",
"message": "One or more properties contains invalid values.",
"innerError":
{
"date": "2022-10-07T06:12:04",
"request-id": "111111-2222-3333-4444-5555555",
"client-request-id": "12345-1234-1234-1234-12345678"
}
}
}
How can I view the log that is referenced with "request-id":"111111-2222-3333-4444-5555555" or "client-request-id":"12345-1234-1234-1234-12345678"?

There is no inbuilt resource to log the requests coming to Azure rest api.
Refer to one of the similar issues regarding REST APIs using in Azure.
Application insights can be used for tracking purpose if your application is deployed in azure.
Created the Web App > created & configured application insights resource:
Go to Overview blade of Web App > requests coming to web app in a graphical representation:
To view logs of webapp, go to web app and click on Logs in Monitoring session.
Example: Below is one failed request to web app can be seen in logs,
Refer to this MS Doc for more information on Azure Monitor App Insight Logging.

Related

How do I access Azure Storage container from Azure Cognitive services

I am having an issue with transcribing (Speech-To-Text) an audio file hosted on Azure Storage container from the Cognitive Services API.
The services are of the same resource (and I created a VNet and they are part of the same subnet).
After I take the response from there the contentUrl:
The error I get is:
{
"successfulTranscriptionsCount": 0,
"failedTranscriptionsCount": 1,
"details": [
{
"source":"https://{service-name}.blob.core.windows.net/meetingnotes/Meeting82035.wav",
"status": "Failed",
"errorMessage": "Error when downloading the recording URI. StatusCode: Conflict.",
"errorKind": "DownloadRecordingsUrisUnknownError"
}
]
}
I tested in my environment and was getting the same error as you.
To resolve the issue, you need to append the SAS Token with bloUrl in contentUrls field.
For Generating the SAS token allowed all the permission as I have done in below picture.
Generated Transcript report
Final OutPut Once Clicked on ContentUrl
I contacted Azure support and they provided the correct solution, which is to add the Role “Storage Blob Data Contributor” to the speech services resources.
Go to IAM of your storage account
Go to Role Assignments
click "Add", then add your speech service in Managed Identities.
That should fix it.

Get VM name for an instance of Azure web app from REST API or PowerShell

I am trying to find a REST API / PowerShell cmdlet to retrieve the VM name(starts with RD) for an instance of Azure web app.
I found out that I can list the process Ids by Instance Id and then get Instance Process with Azure App Service. This object has details including the Machine Name. I'm wondering if there is a better way of doing this, something with lesser API calls perhaps.
Background:
I need to restart a specific instance of a Azure Web app programmatically. Users calling restart can only see the VM name or Role Instance of a web App in Application insights.
I found APIs to list instances but nothing to find mapping between instance Id and VM name directly.
Do you try this API Virtual Machines - List?
By Using this api, you can get id and name from values[]
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines?api-version=2018-06-01
Result example :
{
"value": [
{
// ignore
"id": "/subscriptions/{subscriptionsID}/resourceGroups/test-resource-group/providers/Microsoft.Compute/virtualMachines/my-vmname",
"name": "my-vmname"
}
]
}
You can try to use the REST API Web Apps - List Instance Identifiers to get all scale-out instances of an app.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{name}/instances?api-version=2016-08-01
Actually, the instances for a WebApp by scaling out is for its App Service Plan. For example, I scaled up the instance number of my webapp to 4 on Azure portal, then the instance number of its App Service Plan as the figures below.
And I got the json response from the REST API, as below.

Azure Datafactory Web Activity

I have developed an Function app and published the same via Azure APIM. I am trying to call the API(APIM) from Data factory Web Activity, which fails with the below. However when I use the Azure function URL + Function key directly in WebActivity this works fine.
So I want to be able to call a REST endpoint internal to my organization from Azure Data Factory using Web Activity. Appreciate any directions on this.
{
"errorCode": "2108",
"message": "Error calling the endpoint. Response status code: ",
"failureType": "UserError
}

Azure portal application settings: "Failed to load settings" (ReadOnlyDisabledSubscription)

In the Azure portal I select my web app and then "Application settings" and it shows this:
An error message, "Failed to load settings", for application settings and also for connection strings.
How do I fix this?
Additional information:
Another user with the same privileges than me is also experiencing this issue when going to the same Application settings page. Also I'm able to deploy so I have the privilege to modify web.config
Additional information #2:
So I used Chrome Inspector as suggested and its trying to get application settings with a POST to https://management.azure.com/subscriptions/xxxxxxxxxxx/resourceGroups/xxx/providers/Microsoft.Web/sites/xxx/config/appSettings/list?api-version=2015-08-01
This is the JSON response:
{
"error": {
"code":"ReadOnlyDisabledSubscription",
"message":"The subscription 'xxxxxxxxxx' is disabled and therefore marked as read only. You cannot perform any write actions on this subscription until it is re-enabled."
}
}
Sometimes the Azure portal has bugs.
Also try https://preview.portal.azure.com, occasionally that works for me when the main portal has errors.

Is it possible to access Docker containers living in Azure Container Instance(s) via RESTful endpoints?

I am trying to proof out the ability to store my Docker container in Azure Container Instance. I currently have my container in Azure Container Instance but I am trying to access it via RESTful endpoints.
I have currently configured my Azure AD account to grant my application access to the Windows Azure Service Management API with the delegate access.
I am also using Postman to create the Bearer token to then pass down to my URL:
POST
https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/slack-bots-v2/providers/Microsoft.ContainerInstance/containerGroups/testing/exec?api-version=2018-04-01
I am however getting an error of:
{
"error": {
"code": "AuthorizationFailed",
"message": "The client '<CLIENT_ID>' with object id '<OBJECT_ID>' does not have authorization to perform action 'Microsoft.ContainerInstance/containerGroups/exec/action' over scope '/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/slack-bots-v2/providers/Microsoft.ContainerInstance/containerGroups/testing'."
}
}
Question(s):
is it possible to access my container instance via RESTful API?
is there a different Azure AD permission that needs to be set in order to access this?
has anyone solved a similar problem outside of Azure but maybe with another public cloud provider, (AWS, GCP, and etc)?

Resources