简体   繁体   中英

How to register MS office license through pipeline in Azure VM

I am planning to use MS office in Azure VM in pipeline approach. Below is my flow

  1. I have configured devops pipeline with Azure VM (VMSS). It contains VM image definition on below configuration a.OS: Windows Server 2022 b. Location: East US c. OS State: Generalized
  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.
  3. Now, trying to use MS office (word or excel or anything) for some automation process. But, it is not activated with license key.

Any possibility to apply license for MS office in VM image (created from Azure VM). Because, while creating VM the Appdata things (license, user data) are deleted.

Tried Appium to pick UI element and enter license key through pipeline:

  1. I have tried Appium APIs to pick the current window, buttons and text. Then, decide to click the button based on that. (OpenQA.Selenium.Appium.FindElementByXPath(string xpath))
  2. I am facing privacy option window open again and again. (I figure out this by using printing the list of available text using Appium). Below is the text. “Thanks for using 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.”
  3. Even I have tried to click close button, it clicked then again and again same window opening.

Expecting: It should click the close and go to account settings for license registartion.

There are many libraries for reading and writing office. You do not need to have MS Office activated. Below is my simple test on VM without MS office:

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

And registered the key before creating VM image.

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).

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.

Any idea to click close button using WinAppdriver through pipeline.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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