從 Azure 入口網站將混合式機器連線至 AzureConnect hybrid machines to Azure from the Azure portal

您可以手動執行一組步驟,為環境中的一部或少數幾部 Windows 或 Linux 機器啟用「適用於伺服器的 Azure Arc」(預覽)。You can enable Azure Arc for servers (preview) for one or a small number of Windows or Linux machines in your environment by performing a set of steps manually. 或者,您也可以藉由執行我們所提供的範本指令碼來使用自動化方法。Or you can use an automated method by running a template script that we provide. 此指令碼會自動下載並安裝這兩個代理程式。This script automates the download and installation of both agents.

若要使用這種方法,您必須擁有機器上的系統管理員權限,才能安裝和設定代理程式。This method requires that you have administrator permissions on the machine to install and configure the agent. 在 Linux 上請使用根帳號,在 Windows 上則必須是本機系統管理員群組的成員。On Linux, by using the root account, and on Windows, you are member of the Local Administrators group.

開始之前,請務必檢閱必要條件並確認訂用帳戶和資源已符合需求。Before you get started, be sure to review the prerequisites and verify that your subscription and resources meet the requirements.

如果您沒有 Azure 訂用帳戶,請先建立免費帳戶,再開始進行。If you don't have an Azure subscription, create a free account before you begin.

從 Azure 入口網站產生安裝指令碼Generate the installation script from the Azure portal

用來自動下載和安裝以及用來與 Azure Arc 建立連線的指令碼,可從 Azure 入口網站取得。The script to automate the download and installation, and to establish the connection with Azure Arc, is available from the Azure portal. 若要完成此程序,請執行下列動作:To complete the process, do the following:

  1. 在瀏覽器中,移至 Azure 入口網站From your browser, go to the Azure portal.

  2. 在 [機器 - Azure Arc]**** 頁面上,選取左上角的 [新增]****,或選取中間窗格底部的 [建立機器 - Azure Arc]**** 選項。On the Machines - Azure Arc page, select either Add, at the upper left, or the Create machine - Azure Arc option at the bottom of the middle pane.

  3. 在 [選取方法]**** 頁面上,選取 [使用互動式指令碼新增機器]**** 圖格,然後選取 [產生指令碼]****。On the Select a method page, select the Add machines using interactive script tile, and then select Generate script.

  4. 在 [產生指令碼]**** 頁面上,選取您要在 Azure 中用來管理機器的訂用帳戶和資源群組。On the Generate script page, select the subscription and resource group where you want the machine to be managed within Azure. 選取要用來儲存機器中繼資料的 Azure 位置。Select an Azure location where the machine metadata will be stored.

    注意

    適用於伺服器的 Azure Arc (預覽) 僅支援下欄區域:Azure Arc for servers (preview) supports only the following regions:

    • WestUS2WestUS2
    • WestEuropeWestEurope
    • WestAsiaWestAsia

    在 [總覽]文章中選取區域時,請參閱其他考慮。Review additional considerations when selecting a region here in the Overview article.

  5. 在 [產生指令碼]**** 頁面的 [作業系統]**** 下拉式清單中,選取要作為指令碼執行平台的作業系統。On the Generate script page, in the Operating system drop-down list, select the operating system that the script will be running on.

  6. 如果電腦透過 proxy 伺服器進行通訊以連線到網際網路,請選取 [下一步: Proxy 伺服器]If the machine is communicating through a proxy server to connect to the internet, select Next: Proxy Server.

  7. 在 [Proxy 伺服器]**** 索引標籤上,指定要供機器用來與 Proxy 伺服器通訊的 Proxy 伺服器 IP 位址或名稱與連接埠號碼。On the Proxy server tab, specify the proxy server IP address or the name and port number that the machine will use to communicate with the proxy server. 請以 http://<proxyURL>:<proxyport> 格式輸入值。Enter the value in the format http://<proxyURL>:<proxyport>.

  8. 選取 [檢閱 + 產生]****。Select Review + generate.

  9. 在 [檢閱 + 產生]**** 索引標籤上檢閱摘要資訊,然後選取 [下載]****。On the Review + generate tab, review the summary information, and then select Download. 如果您還需要變更,請選取 [上一步]****。If you still need to make changes, select Previous.

在 Windows 上安裝和驗證代理程式Install and validate the agent on Windows

手動安裝Install manually

您可以執行 Windows Installer 套件「AzureConnectedMachineAgent.msi」** 來手動安裝 Azure Connected Machine 代理程式。You can install the Connected Machine agent manually by running the Windows Installer package AzureConnectedMachineAgent.msi.

注意

  • 若要安裝或解除安裝此代理程式,您必須具有「系統管理員」** 權限。To install or uninstall the agent, you must have Administrator permissions.
  • 您必須先下載安裝程式套件,並將其複製到目標伺服器上的資料夾,或從共用的網路資料夾執行此動作。You must first download and copy the Installer package to a folder on the target server, or from a shared network folder. 如果您在執行此安裝程式套件時未使用任何選項,則會啟動以互動方式安裝代理程式的安裝精靈。If you run the Installer package without any options, it starts a setup wizard that you can follow to install the agent interactively.

如果機器需要透過 Proxy 伺服器與服務通訊,則在安裝代理程式之後,您必須執行本文稍後所述的命令。If the machine needs to communicate through a proxy server to the service, after you install the agent you need to run a command that's described later in the article. 這會設定 Proxy 伺服器系統環境變數 https_proxyThis sets the proxy server system environment variable https_proxy.

如果您不熟悉 Windows Installer 封裝的命令列選項,請參閱Msiexec 標準命令列選項Msiexec 命令列選項If you are unfamiliar with the command-line options for Windows Installer packages, review Msiexec standard command-line options and Msiexec command-line options.

例如,請使用/?參數來執行安裝程式,以查看 [說明] 和 [快速參考] 選項。For example, run the installation program with the /? parameter to review the help and quick reference option.

msiexec.exe /i AzureConnectedMachineAgent.msi /?

若要以無訊息模式安裝代理程式,並在存在C:\Support\Logs的資料夾中建立安裝記錄檔,請執行下列命令。To install the agent silently and create a setup log file in the C:\Support\Logs folder that exist, run the following command.

msiexec.exe /i AzureConnectedMachineAgent.msi /qn /l*v "C:\Support\Logs\Azcmagentsetup.log"

連線機器代理程式的檔案預設會安裝在C:\Program Files\AzureConnectedMachineAgent中。Files for the Connected Machine agent are installed by default in C:\Program Files\AzureConnectedMachineAgent. 如果此代理程式在安裝完成之後無法啟動,請檢查記錄以取得詳細的錯誤資訊。If the agent fails to start after setup is finished, check the logs for detailed error information. 記錄目錄是「%Programfiles%\AzureConnectedMachineAgentAgent\logs」**。The log directory is %Programfiles%\AzureConnectedMachineAgentAgent\logs.

使用指令碼方法來安裝Install with the scripted method

  1. 登入伺服器。Log in to the server.

  2. 開啟已提高權限的 PowerShell 命令提示字元。Open an elevated PowerShell command prompt.

  3. 變更至作為指令碼複製目的地的資料夾或共用,然後在伺服器上執行 ./OnboardingScript.ps1 指令碼來執行此工作。Change to the folder or share that you copied the script to, and execute it on the server by running the ./OnboardingScript.ps1 script.

設定代理程式 Proxy 設定Configure the agent proxy setting

若要設定 Proxy 伺服器環境變數,請執行下列命令:To set the proxy server environment variable, run the following command:

# If a proxy server is needed, execute these commands with the proxy URL and port.
[Environment]::SetEnvironmentVariable("https_proxy", "http://{proxy-url}:{proxy-port}", "Machine")
$env:https_proxy = [System.Environment]::GetEnvironmentVariable("https_proxy","Machine")
# For the changes to take effect, the agent service needs to be restarted after the proxy environment variable is set.
Restart-Service -Name himds

注意

本代理程式不支援在此預覽版中設定 Proxy 驗證。The agent does not support setting proxy authentication in this preview.

設定代理程式通訊Configure agent communication

在安裝代理程式後,您必須執行下列命令,將代理程式設定為與 Azure Arc 服務進行通訊:After installing the agent, you need to configure the agent to communicate with the Azure Arc service by running the following command:

"%ProgramFiles%\AzureConnectedMachineAgent\azcmagent.exe" connect --resource-group "<resourceGroupName>" --tenant-id "<tenantID>" --location "<regionName>" --subscription-id "<subscriptionID>"

在 Linux 上安裝和驗證代理程式Install and validate the agent on Linux

適用於 Linux 的 Connected Machine 代理程式會以發行版本慣用的套件格式來提供 (.RPM 或 .DEB),其裝載位置在 Microsoft 的套件存放庫The Connected Machine agent for Linux is provided in the preferred package format for the distribution (.RPM or .DEB) that's hosted in the Microsoft package repository. 殼層指令碼套件組合 Install_linux_azcmagent.sh 會執行下列動作:The shell script bundle Install_linux_azcmagent.sh performs the following actions:

  • 設定主機電腦使其從 packages.microsoft.com 下載代理程式套件。Configures the host machine to download the agent package from packages.microsoft.com.
  • 安裝混合式資源提供者套件。Installs the Hybrid Resource Provider package.

(選擇性) 您可以納入 --proxy "{proxy-url}:{proxy-port}" 參數,以使用 Proxy 資訊來設定代理程式。Optionally, you can configure the agent with your proxy information by including the --proxy "{proxy-url}:{proxy-port}" parameter.

此指令碼也包含用來識別可支援和不支援發行版本的邏輯,並會驗證用來執行安裝所需的權限。The script also contains logic to identify the supported and unsupported distributions, and it verifies the permissions that are required to perform the installation.

下列範例會下載並安裝代理程式:The following example downloads the agent and installs it:

# Download the installation package.
wget https://aka.ms/azcmagent -O ~/Install_linux_azcmagent.sh

# Install the connected machine agent. 
bash ~/Install_linux_azcmagent.sh

若要下載並安裝代理程式,包括用來將代理程式設定為透過 Proxy 伺服器進行通訊的 --proxy 參數,請執行下列命令:To download and install the agent, including the --proxy parameter for configuring the agent to communicate through your proxy server, run the following commands:

# Download the installation package.
wget https://aka.ms/azcmagent -O ~/Install_linux_azcmagent.sh

# Install the connected machine agent. 
bash ~/Install_linux_azcmagent.sh --proxy "{proxy-url}:{proxy-port}"

設定代理程式通訊Configure the agent communication

安裝好代理程式後,請執行下列命令將其設定為與 Azure Arc 服務進行通訊:After you install the agent, configure it to communicate with the Azure Arc service by running the following command:

azcmagent connect --resource-group "<resourceGroupName>" --tenant-id "<tenantID>" --location "<regionName>" --subscription-id "<subscriptionID>"

確認與 Azure Arc 的連線Verify the connection with Azure Arc

在安裝好代理程式並將其設定為連線至適用於伺服器的 Azure Arc (預覽) 之後,請移至 Azure 入口網站以確認伺服器已成功連線。After you install the agent and configure it to connect to Azure Arc for servers (preview), go to the Azure portal to verify that the server has been successfully connected. Azure 入口網站中檢視您的機器。View your machines in the Azure portal.

成功的伺服器連線

後續步驟Next steps

  • 瞭解如何使用Azure 原則來管理您的機器,例如 VM來賓設定、確認機器回報至預期的 Log Analytics 工作區、使用vm 的 Azure 監視器來啟用監視等功能。Learn how to manage your machine using Azure Policy, for such things as VM guest configuration, verifying the machine is reporting to the expected Log Analytics workspace, enable monitoring with Azure Monitor with VMs, and much more.

  • 深入瞭解Log Analytics 代理程式Learn more about the Log Analytics agent. 您需要適用於 Windows 和 Linux 的 Log Analytics 代理程式來主動監視機器上執行的作業系統和工作負載、使用自動化 Runbook 或解決方案 (例如更新管理) 來管理機器,或使用其他 Azure 服務 (例如 Azure 資訊安全中心)。The Log Analytics agent for Windows and Linux is required when you want to proactively monitor the OS and workloads running on the machine, manage it using Automation runbooks or solutions like Update Management, or use other Azure services like Azure Security Center.