简体   繁体   English

如何在 Azure VM 中通过管道注册 MS Office 许可证

[英]How to register MS office license through pipeline in Azure VM

I am planning to use MS office in Azure VM in pipeline approach.我计划在 Azure VM 管道方法中使用 MS office Below is my flow下面是我的流程

  1. I have configured devops pipeline with Azure VM (VMSS).我已经使用 Azure VM (VMSS) 配置了 devops 管道。 It contains VM image definition on below configuration a.它包含以下配置的 VM 映像定义OS: Windows Server 2022 b.操作系统:Windows 服务器 2022 b。 Location: East US c. OS State: Generalized位置:美国东部 c。操作系统 State:通用
  2. I have installed MS office 2019 in VM like this approach https://learn.microsoft.com/en-us/deployoffice/office2019/deploy and created VM image for pipeline works.我已经像这种方法https://learn.microsoft.com/en-us/deployoffice/office2019/deploy一样在 VM 中安装了 MS office 2019,并为管道工程创建了 VM 映像。
  3. Now, trying to use MS office (word or excel or anything) for some automation process.现在,尝试将 MS office(word 或 excel 或任何东西)用于某些自动化过程。 But, it is not activated with license key.但是,它没有使用许可证密钥激活。

Any possibility to apply license for MS office in VM image (created from Azure VM).在 VM 映像(从 Azure VM 创建)中申请 MS office 许可证的任何可能性 Because, while creating VM the Appdata things (license, user data) are deleted.因为,在创建 VM 时,Appdata 的东西(许可证、用户数据)被删除了。

Tried Appium to pick UI element and enter license key through pipeline:尝试 Appium 选择 UI 元素并通过管道输入许可证密钥:

  1. I have tried Appium APIs to pick the current window, buttons and text.我已经尝试使用 Appium API 来选择当前的 window、按钮和文本。 Then, decide to click the button based on that.然后,决定基于此单击按钮。 (OpenQA.Selenium.Appium.FindElementByXPath(string xpath)) (OpenQA.Selenium.Appium.FindElementByXPath(字符串 xpath))
  2. I am facing privacy option window open again and again.我面临一次又一次打开的隐私选项 window。 (I figure out this by using printing the list of available text using Appium). (我通过使用 Appium 打印可用文本列表来解决这个问题)。 Below is the text.以下是正文。 “Thanks for using Office. “感谢使用 Office。 We've made some updates to the privacy settings to give you more control.我们对隐私设置进行了一些更新,以便为您提供更多控制权。 Your organization's admin allows you to use several cloud-backed services.您组织的管理员允许您使用多个云支持的服务。 You get to decide whether you use these services, To adjust these privacy settings.您可以决定是否使用这些服务,调整这些隐私设置。 go to File > Options > Trust Center > Trust Center Settings > Privacy Options These optional cloud-backed services are provided to you under the Microsoft Services Agreement.” go 到文件 > 选项 > 信任中心 > 信任中心设置 > 隐私选项这些可选的云支持服务是根据 Microsoft 服务协议提供给你的。”
  3. Even I have tried to click close button, it clicked then again and again same window opening.即使我尝试单击关闭按钮,它也会一次又一次地单击相同的 window 打开。

Expecting: It should click the close and go to account settings for license registartion.预期:它应该点击关闭和go到帐户设置以进行许可证注册。

There are many libraries for reading and writing office.有许多图书馆可供阅读和写作办公。 You do not need to have MS Office activated.您不需要激活 MS Office。 Below is my simple test on VM without MS office:下面是我在没有 MS office 的情况下对 VM 的简单测试:

using NPOI.HSSF.UserModel;
using NPOI.POIFS.Crypt.Dsig;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;

namespace ConsoleApp1
{
    internal class Program
    {



        static void Main(string[] args)
        {
           
            DataTable dt = new DataTable();

            HSSFWorkbook hssfworkbook;
            using (FileStream file = new FileStream("../../../test.xls", FileMode.Open, FileAccess.Read))
            {
                hssfworkbook = new HSSFWorkbook(file);
            }
            HSSFSheet sheet = (HSSFSheet)hssfworkbook.GetSheetAt(0);
            System.Collections.IEnumerator rows = sheet.GetRowEnumerator();

            HSSFRow headerRow = (HSSFRow)sheet.GetRow(0);
            int cellCount = headerRow.LastCellNum;

            for (int j = 0; j < cellCount; j++)
            {
                HSSFCell cell = (HSSFCell)headerRow.GetCell(j);
                dt.Columns.Add(cell.ToString());
                Console.WriteLine(cell.ToString());
            }

            for (int i = (sheet.FirstRowNum + 1); i <= sheet.LastRowNum; i++)
            {
                HSSFRow row = (HSSFRow)sheet.GetRow(i);
                DataRow dataRow = dt.NewRow();

                for (int j = row.FirstCellNum; j < cellCount; j++)
                {
                    if (row.GetCell(j) != null)
                        dataRow[j] = row.GetCell(j).ToString();
                }

                dt.Rows.Add(dataRow);
            }
            ....

I tried some steps and finally installed office like this https://learn.microsoft.com/en-us/deployoffice/office2019/deploy我尝试了一些步骤,最后像这样安装了办公室https://learn.microsoft.com/en-us/deployoffice/office2019/deploy

And registered the key before creating VM image.并在创建 VM 映像之前注册密钥。

Now, product license not remove.现在,产品许可证未删除。 I can able to see MS office is licensed (if I created VM again using that sample VM image definition).我可以看到 MS Office 已获得许可(如果我使用该示例 VM 映像定义再次创建 VM)。

Now, I am facing problem while launching office product (excel, word, outlook), "Accept and start excel", "Your privacy option" these windows are showing again and again.现在,我在启动办公产品(excel、word、outlook)时遇到问题,“接受并启动 excel”、“您的隐私选项”这些 windows 一次又一次地显示。

Any idea to click close button using WinAppdriver through pipeline.通过管道使用 WinAppdriver 单击关闭按钮的任何想法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM