Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/291.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
C# 获取Azure';文件和文件夹';使用Powershell或C的作业状态#_C#_Powershell_Azure_Backup - Fatal编程技术网

C# 获取Azure';文件和文件夹';使用Powershell或C的作业状态#

C# 获取Azure';文件和文件夹';使用Powershell或C的作业状态#,c#,powershell,azure,backup,C#,Powershell,Azure,Backup,我一直在试图找到一种方法来获取在AzureRM中运行的几个客户上运行的“文件和文件夹”备份作业的状态。可以在AzureRm门户中使用手动方式从以下位置找到状态: “恢复服务保险库”->作业->备份作业 使用powershell不会显示任何作业信息 Get-AzureRmRecoveryServicesVault | Set-AzureRmRecoveryServicesVaultContext Get-AzureRmRecoveryServicesBackupContainer -Contain

我一直在试图找到一种方法来获取在AzureRM中运行的几个客户上运行的“文件和文件夹”备份作业的状态。可以在AzureRm门户中使用手动方式从以下位置找到状态: “恢复服务保险库”->作业->备份作业

使用powershell不会显示任何作业信息

Get-AzureRmRecoveryServicesVault | Set-AzureRmRecoveryServicesVaultContext
Get-AzureRmRecoveryServicesBackupContainer -ContainerType Windows -BackupManagementType MARS |fl
Get-AzureRmRecoveryServicesBackupJob
尝试过使用C#,但如果可能的话,还没有找到通过这种方式获取信息的方法

using Microsoft.Azure.Management.RecoveryServices.Backup;
var creds = new Microsoft.Azure.TokenCloudCredentials(subscriptionId, token);
IRecoveryServicesBackupManagementClient client = new RecoveryServicesBackupManagementClient(creds);
Console.WriteLine(client.Jobs.ToString());
有什么想法吗

尝试过使用C#,但如果可能的话,还没有找到通过这种方式获取信息的方法

using Microsoft.Azure.Management.RecoveryServices.Backup;
var creds = new Microsoft.Azure.TokenCloudCredentials(subscriptionId, token);
IRecoveryServicesBackupManagementClient client = new RecoveryServicesBackupManagementClient(creds);
Console.WriteLine(client.Jobs.ToString());
我用它做了一个演示。对我来说,它工作正常

如何创建身份验证文件,请参阅

演示代码

  var subscriptionId = "subscriptionId";
  var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"Auth file path");
  var client = new RecoveryServicesBackupClient(credentials) {SubscriptionId = subscriptionId };
  var result = client.BackupJobs.List("vaultName", "resource Group").First();
  var workloadType = ((MabJob) result.Properties).WorkloadType;

Packages.config

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Hyak.Common" version="1.0.2" targetFramework="net461" />
  <package id="Microsoft.Azure.Common" version="2.1.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net461" />
  <package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.AppService.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Batch.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.BatchAI.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Cdn.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Compute.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.ContainerInstance.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.ContainerRegistry.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.ContainerService.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.CosmosDB.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Dns.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.EventHub.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Graph.RBAC.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.KeyVault.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Locks.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Monitor.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Msi.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Network.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.RecoveryServices.Backup" version="2.1.0-preview" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Redis.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.ResourceManager.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Search.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.ServiceBus.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Sql.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.Storage.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Azure.Management.TrafficManager.Fluent" version="1.8.0" targetFramework="net461" />
  <package id="Microsoft.Bcl" version="1.1.9" targetFramework="net461" />
  <package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net461" />
  <package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net461" />
  <package id="Microsoft.Data.Edm" version="5.8.2" targetFramework="net461" />
  <package id="Microsoft.Data.OData" version="5.8.2" targetFramework="net461" />
  <package id="Microsoft.Data.Services.Client" version="5.8.2" targetFramework="net461" />
  <package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="2.28.3" targetFramework="net461" />
  <package id="Microsoft.Net.Http" version="2.2.22" targetFramework="net461" />
  <package id="Microsoft.Rest.ClientRuntime" version="2.3.9" targetFramework="net461" />
  <package id="Microsoft.Rest.ClientRuntime.Azure" version="3.3.10" targetFramework="net461" />
  <package id="Microsoft.Rest.ClientRuntime.Azure.Authentication" version="2.3.2" targetFramework="net461" />
  <package id="Newtonsoft.Json" version="6.0.8" targetFramework="net461" />
  <package id="System.ComponentModel.EventBasedAsync" version="4.0.11" targetFramework="net461" />
  <package id="System.Dynamic.Runtime" version="4.0.0" targetFramework="net461" />
  <package id="System.Linq.Queryable" version="4.0.0" targetFramework="net461" />
  <package id="System.Net.Requests" version="4.0.11" targetFramework="net461" />
  <package id="System.Spatial" version="5.8.2" targetFramework="net461" />
  <package id="WindowsAzure.Storage" version="8.1.4" targetFramework="net461" />
</packages>


您可以在此处查看使用Get-AzureRmRecoveryServicesBackupJob获取备份作业列表的示例:参考:。Hi@Swikruti Bose,Get-AzureRmRecoveryServicesBackupJob仅显示我的“AzureVM”备份,但不显示任何“MARS”备份。您可以参考此文档:并查看它是否有帮助。其中也没有任何内容,只是本地管理的powershell命令…谢谢Tom,我必须使用预览,然后我才能列出工作状态