Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用PowerShell在Azure SQL数据库中启用诊断_Powershell_Azure_Azure Powershell_Azure Sql Database - Fatal编程技术网

使用PowerShell在Azure SQL数据库中启用诊断

使用PowerShell在Azure SQL数据库中启用诊断,powershell,azure,azure-powershell,azure-sql-database,Powershell,Azure,Azure Powershell,Azure Sql Database,如何使用PowerShell在Azure SQL数据库中启用诊断 我正在使用Powershell创建数据库&同时,在创建数据库之后,我希望启用保留天数为1的诊断日志 非常感谢您的帮助。是的,我们可以使用PowerShell命令设置AzureRmDiagnosticSetting来启用它,以下是我的脚本: $storage = Get-AzureRmStorageAccount -ResourceGroupName sql -Name jasondisk321 $storageid = $stor

如何使用PowerShell在Azure SQL数据库中启用诊断

我正在使用Powershell创建数据库&同时,在创建数据库之后,我希望启用保留天数为1的诊断日志


非常感谢您的帮助。

是的,我们可以使用PowerShell命令
设置AzureRmDiagnosticSetting
来启用它,以下是我的脚本:

$storage = Get-AzureRmStorageAccount -ResourceGroupName sql -Name jasondisk321
$storageid = $storage.id
$resoure = Find-AzureRmResource -ResourceNameContains "sql"
$id = $resoure.ResourceId
PS C:\windows\system32> Set-AzureRmDiagnosticSetting -ResourceId $id -StorageAccountId $storageid -RetentionEnabled $true -RetentionInDays "1" -Enabled $true


StorageAccountId : /subscriptions/5384xxxx-xxxx-xxxx-xxxx-xxxxe29axxxx/resourceGroups/sql/providers/Microsoft.Storage/storageAccounts/jasondisk321
ServiceBusRuleId :
Metrics          : {Microsoft.Azure.Management.Insights.Models.MetricSettings}
Logs             : {}
WorkspaceId      :
Id               : /subscriptions/5384xxxx-xxxx-xxxx-xxxx-xxxxe29axxxx/resourcegroups/sql/providers/microsoft.sql/servers/jason321/databases/jasonsql/providers/microsoft.insights/diagnosticSettings/service
Name             : service
Type             :
Location         :
Tags             :