如何获取Sharepoint在线迁移API日志(使用c#)

问题描述:

使用`Sharepoint.Client`版本16包,我们尝试在c#中创建`MigrationJob`,然后想要查看该迁移作业的状态和日志。我们设法使用`Site`对象上的`ProvisionMigrationContainers`
和`Pr​​ovisionMigrationQueue`方法来配置容器和队列。我们设法上传了一些文件和清单XML。这些XML仍然包含id和结构中的一些错误,因此我们希望作业失败。但是,我们仍然期望创建作业,并且
输出一些消息和日志。不幸的是,消息队列似乎是空的,并且无法找到日志(至少我们找不到它们)。创建的迁移作业的Guid是null guid:`00000000-0000-0000-0000-000000000000`



根据https://docs.microsoft.com / en-us / sharepoint / dev / apis / migration-api-overview应将日志作为blob保存在清单容器中。但是,您如何实际找到日志文件的名称?问题是所有内容都必须加密
并且不允许列出blob存储中的blob(尝试这会导致403错误)。



所以主要问题是:我们如何访问日志文件?还有一个问题:假设创建迁移作业的命令是正确的,为什么我们得到null guid?最后一个:为什么队列空了?我可以推测永远不会创建
迁移作业,这就是guid全为零的原因,但我们怎么知道阻止创建作业的原因呢?



以下是创建迁移作业的代码:



  &NBSP; public ClientResult< Guid> CreateMigrationJob()

  &NBSP; {

  &NBSP; &NBSP; var encryption = new EncryptionOption

  &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; AES256CBCKey = encryptionProvider.Key

  &NBSP; &NBSP; };
  &NBSP; &NBSP; return context.Site.CreateMigrationJobEncrypted(

     context.Web.Id, 

     dataContainer.Uri .ToString(), 

     metadataContainer.Uri.ToString(), 

     migrationQueue .Uri.ToString(), 

    加密

   );

&NBSP; &NBSP; }
`context`,`dataContainer`,`metadataContainer`都已正确实例化为成员,并已成功用于其他方法。 `migrationQueue`和`encryption`也看起来不错,但还没有在其他地方使用过。加密密钥一直是
用于上传和下载文件,并在那里工作得非常好。



为了完整起见,这里是我们尝试使用的代码检查队列中是否有任何内容:



  &NBSP; public void GetMigrationLog()

  &NBSP; {

  &NBSP; &NBSP;虽然(migrationQueue.ApproximateMessageCount> 0)//调试代码,但这应该是异步的。
  &NBSP; &NBSP; {

  &NBSP; &NBSP; &NBSP; Console.WriteLine(migrationQueue.GetMessage()。AsString);

  &NBSP; &NBSP; }¥b $ b  &NBSP; }
它什么都不输出,因为队列是空的。我们希望至少会出现一条错误消息或创建日志的消息(包括日志文件的名称)。

Using the `Sharepoint.Client` version 16 package, we are trying to create a `MigrationJob` in c# and then subsequently want to see the status and logs of that migration job. We managed to provision the containers and queue using the `ProvisionMigrationContainers` and `ProvisionMigrationQueue` methods on the `Site` object. And we managed to upload some files and manifest XMLs. These XMLs still contain some errors in the ids and structure, so we expect the job to fail. However, we still expect the job to be created and output some messages and logs. Unfortunately the message queue seems to be empty and the logs are nowhere to be found (at least we can't find them). The Guid of the created migration job is the null guid: `00000000-0000-0000-0000-000000000000`

According to https://docs.microsoft.com/en-us/sharepoint/dev/apis/migration-api-overview the logs should be saved in the manifest container as a blob. But how would you actually find the name of the log file? The problem is that everything has to be encrypted and it is not allowed to list the blobs in the blob storage (trying this leads to a 403 error).

So the main question is: how are we supposed to access the log files? And the bonus question: assuming that the command to create the migration job is correct, why are we getting the null guid? And last one: why is the queue empty? I could speculate that the migration job is never created and that's why the guid is all zeroes, but how are we supposed to know what is preventing the job from being created?

Here is the code that creates the Migration Job:

    public ClientResult<Guid> CreateMigrationJob()
    {
      var encryption = new EncryptionOption
      {
        AES256CBCKey = encryptionProvider.Key
      };
      return context.Site.CreateMigrationJobEncrypted(
        context.Web.Id, 
        dataContainer.Uri.ToString(), 
        metadataContainer.Uri.ToString(), 
        migrationQueue.Uri.ToString(), 
        encryption
      );
    }
`context`, `dataContainer`, `metadataContainer` have all been properly instantiated as members and have been used in other methods successfully. `migrationQueue` and `encryption` also look fine, but have not been used elsewhere. The encryption key has been used to upload and download files though and works perfectly fine there.

For completeness sake, here is the code we tried to use to check if there is anything in the queue:

    public void GetMigrationLog()
    {
      while (migrationQueue.ApproximateMessageCount > 0) //debug code, this should be done async
      {
        Console.WriteLine(migrationQueue.GetMessage().AsString);
      }
    }
It outputs nothing, because the queue is empty. We would expect there to be at least an error message or a message that the logs were created (including the name of the log file).

顺便说一下:我试图在Sharepoint Online论坛上发布这个,但似乎没有一个(这里的SP的最后一个版本是2013)。有没有人建议比这个更好的位置?
By the way: I tried to post this in a Sharepoint Online forum, but it seems there isn't one (last version of SP here is 2013). Anyone have a suggestion for a better location than this one?