i tried to get all operations (Get, Put, Delete)etc.. on a specific storage account but I don't get all information (on which container, on which blob)..
I tried these two api : 1)
https://management.azure.com/subscriptions/XXX/resourceGroups/XXX/providers/Microsoft.Storage/storageAccounts/XXX/providers/microsoft.insights/metrics?metricnames=Transactions×pan=2022-12-18T02:00:00Z/2022-12-20T02:05:00Z&\$filter=apiname eq '*' and ResponseType eq '*' &interval=PT24H&aggregation=Total&orderby=Total desc&api-version=2019-07-01
but I get only the number and the response type
CodePudding user response:
Use the below params as headers to get rid of un- authorization error while accessing the API
x-ms-date : x-ms-version : Authorization : SharedKey storagename: Signature
Authorization is shown in below snippet
Create a storage account and container in Azure
Storage account
Container
code in C# to fetch the Headers of x-ms-date , x-ms-version , and Authorization
using (var Req = new HttpRequestMessage(HttpMethod.Get, uri)
{ Content = (requestPayload == null) ? null : new ByteArrayContent(requestPayload) })
{
DateTime now = DateTime.UtcNow;
Req.Headers.Add("x-ms-date", now.ToString("2022-12-26 8:40:16 PM", CultureInfo.InvariantCulture));
Req.Headers.Add("x-ms-version", "2022-09-01");
Req.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
storageAccountName, storageAccountKey, now, Req);
using (HttpResponseMessage Resp = await new HttpClient().SendAsync(Req, cancellationToken))
{
if (Resp.StatusCode == HttpStatusCode.OK)
{
String xmlString = await Resp.Content.ReadAsStringAsync();
XElement x = XElement.Parse(xmlString);
foreach (XElement container in x.Element("Containers").Elements("Container"))
{
Console.WriteLine("Container name = {0}", container.Element("Name").Value);
}
}
}
}
for more information, please check this link
CodePudding user response:
Data layer operations are available on resource log(diagnostics logs).
Refer documentation how to enable logging into log analytics workspace: https://learn.microsoft.com/en-us/azure/storage/blobs/monitor-blob-storage?tabs=azure-portal#collection-and-routing
After turning on logging you can run queries to fetch operation from StorageBlobLogs
table.