az ad sp create-for-rbac --name "PORJECTNAME" --role contributor --scopes /subscriptions/abcdefgh-1234-4321-5678-abcdefabcdef/resourceGroups/GROUP_NAME/providers/Microsoft.Storage/storageAccounts/STORAGENAME
var credentials = SdkContext.AzureCredentialsFactory.FromServicePrincipal(
clientId,
clientSecret,
tenatId, AzureEnvironment.AzureGlobalCloud);
var azure = Microsoft.Azure.Management.Fluent.Azure.Configure()
.WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
.Authenticate(credentials)
.WithDefaultSubscription();
var logs = azure.ActivityLogs.DefineQuery()
.StartingFrom(DateTime.Now.AddHours(-24))
.EndsBefore(DateTime.Now)
.WithAllPropertiesInResponse()
.FilterByResource("/subscriptions/SUBSCRIPTIONID/resourceGroups/RESOURCENAME/providers/Microsoft.Storage/storageAccounts/STORAGENAME")
.Execute();
Console.WriteLine("Check Traffic Manager Activity Logs : ");
var i = 0;
foreach (var eventLog in logs)
{
Console.WriteLine("時間: " + eventLog.EventTimestamp.Value.ToString("yyyy-MM-dd HH:mm:ss"));
string json = JsonConvert.SerializeObject(eventLog, Formatting.Indented);
Console.WriteLine(json);
Console.WriteLine("--------");
}
結果:
這樣你就可以透過程式的方法去拿到log 拿到你要的資訊。
--
Before you read this, the article was in a superposition of human and AI. Upon observation, the wave function collapsed into a sleep-deprived developer.