GET https://management.azure.com/subscriptions/df602c9c-7aa0-407d-a6fb-eb20c8bd1192/providers/Microsoft.Insights/logprofiles/default?api-version=2016-03-01
import com.azure.core.util.Context;
/** Samples for LogProfiles Get. */
public final class Main {
/*
* x-ms-original-file: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json
*/
/**
* Sample code: Get log profile.
*
* @param azure The entry point for accessing resource management APIs in Azure.
*/
public static void getLogProfile(com.azure.resourcemanager.AzureResourceManager azure) {
azure.diagnosticSettings().manager().serviceClient().getLogProfiles().getWithResponse("default", Context.NONE);
}
}
using System;
using System.Threading.Tasks;
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.Monitor;
using Azure.ResourceManager.Monitor.Models;
using Azure.ResourceManager.Resources;
// Generated from example definition: specification/monitor/resource-manager/Microsoft.Insights/stable/2016-03-01/examples/getLogProfile.json
// this example is just showing the usage of "LogProfiles_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this SubscriptionResource created on azure
// for more information of creating SubscriptionResource, please refer to the document of SubscriptionResource
string subscriptionId = "df602c9c-7aa0-407d-a6fb-eb20c8bd1192";
ResourceIdentifier subscriptionResourceId = SubscriptionResource.CreateResourceIdentifier(subscriptionId);
SubscriptionResource subscriptionResource = client.GetSubscriptionResource(subscriptionResourceId);
// get the collection of this LogProfileResource
LogProfileCollection collection = subscriptionResource.GetLogProfiles();
// invoke the operation
string logProfileName = "default";
NullableResponse<LogProfileResource> response = await collection.GetIfExistsAsync(logProfileName);
LogProfileResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine($"Succeeded with null as result");
}
else
{
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
LogProfileData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
Error message indicating why the operation failed.
LogProfileResource
The log profile resource.
Name
Type
Description
id
string
Azure resource Id
location
string
Resource location
name
string
Azure resource name
properties.categories
string[]
the categories of the logs. These categories are created as is convenient to the user. Some values are: 'Write', 'Delete', and/or 'Action.'
properties.locations
string[]
List of regions for which Activity Log events should be stored or streamed. It is a comma separated list of valid ARM locations including the 'global' location.
The service bus rule ID of the service bus namespace in which you would like to have Event Hubs created for streaming the Activity Log. The rule ID is of the format: '{service bus resource ID}/authorizationrules/{key name}'.
properties.storageAccountId
string
the resource id of the storage account to which you would like to send the Activity Log.
tags
object
Resource tags
type
string
Azure resource type
RetentionPolicy
Specifies the retention policy for the log.
Name
Type
Description
days
integer
the number of days for the retention in days. A value of 0 will retain the events indefinitely.
enabled
boolean
a value indicating whether the retention policy is enabled.