Anslut en befintlig Linux-server till Azure-bågenConnect an existing Linux server to Azure Arc
Den här artikeln innehåller rikt linjer för att ansluta en Linux-server till en Azure-båge med ett enkelt gränssnitts skript.This article provides guidance for connecting a Linux server to Azure Arc using a simple shell script.
FörutsättningarPrerequisites
Installera eller uppdatera Azure CLI till version 2,7 och senare.Install or update Azure CLI to version 2.7 and above. Använd följande kommando för att kontrol lera den aktuella installerade versionen.Use the following command to check your current installed version.
az --version
Skapa ett huvud namn för Azure-tjänsten.Create an Azure service principal.
För att ansluta en server till en Azure-båge krävs ett Azure-tjänstens huvud namn som tilldelats deltagar rollen.To connect a server to Azure Arc, an Azure service principal assigned with the Contributor role is required. Om du vill skapa den loggar du in på ditt Azure-konto och kör följande kommando.To create it, sign in to your Azure account and run the following command. Du kan också köra det här kommandot i Azure Cloud Shell.You can also run this command in Azure Cloud Shell.
az login az ad sp create-for-rbac -n "<Unique SP Name>" --role contributor
Exempel:For example:
az ad sp create-for-rbac -n "http://AzureArcServers" --role contributor
Utdata bör se ut så här:Output should look like this:
{ "appId": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "displayName": "AzureArcServers", "name": "http://AzureArcServers", "password": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX", "tenant": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX" }
Anteckning
Vi rekommenderar starkt att du omfångerar tjänstens huvud namn till en Azure-prenumeration och en unik resurs grupp.We highly recommend that you scope the service principal to a specific Azure subscription and resource group.
Skapa en ny Azure-resurs grupp för dina servrar.Create a new Azure resource group for your servers.
Ladda ned
az_connect_linux
Shell-skriptet.Download theaz_connect_linux
shell script.Ändra miljövariablerna enligt din miljö.Change the environment variables according to your environment.
Kopiera skriptet till den utsedda servern med önskat alternativ (eller kopiera/klistra in skriptet till en ny fil i servern).Copy the script to the designated server using your preferred tool of choice (or copy/paste the script to a new file inside the server). I följande exempel visas hur du kopierar skriptet från macOS till servern med hjälp av
scp
.The following example shows how to copy the script from macOS to the server usingscp
.
DistributionDeployment
Kör skriptet med . ./az_connect_linux.sh
kommandot.Run the script using the . ./az_connect_linux.sh
command.
Anteckning
Den extra punkten beror på att skriptet har en export funktion och måste ha kopplingsvariabler exporter ATS i samma Shell-session som resten av kommandona.The extra dot is because the script has an export function and needs to have the vars exported in the same shell session as the rest of the commands.
När du är klar har du en Linux-server som är ansluten som en ny Azure Arc-resurs i din resurs grupp.Upon successful completion, you will have your Linux server, connected as a new Azure Arc resource inside your resource group.
Ta bort distributionenDelete the deployment
Om du vill ta bort servern väljer du servern och tar bort den från Azure Portal.To delete the server, select the server and delete it from the Azure portal.
Ta bort hela distributionen genom att ta bort Azure-resurs gruppen från Azure Portal.To delete the entire deployment, delete the Azure resource group from the Azure portal.