Questa sezione illustra la configurazione dell'interfaccia della riga di comando se si usa Azure AD come servizio di gestione delle identità e si usa l'interfaccia della riga di comando in un computer Windows.This section walks you through setting up CLI if you're using Azure AD as your identity management service, and are using CLI on a Windows machine.
Connettersi all'hub Azure StackConnect to Azure Stack Hub
Se si usa Gabriele, considerare attendibile il certificato radice CA dell'hub Azure Stack.If you are using the ASDK, trust the Azure Stack Hub CA root certificate. Per istruzioni, vedere attendibilità del certificato.For instruction, see Trust the certificate.
Registrare l'ambiente dell'hub Azure Stack eseguendo il az cloud register
comando.Register your Azure Stack Hub environment by running the az cloud register
command.
Registrare l'ambiente.Register your environment. Quando si esegue, usare i parametri seguenti az cloud register
:Use the following parameters when running az cloud register
:
ValoreValue |
EsempioExample |
DescrizioneDescription |
Nome ambienteEnvironment name |
AzureStackUserAzureStackUser |
Usare AzureStackUser per l'ambiente utente.Use AzureStackUser for the user environment. Se si è operatore, specificare AzureStackAdmin .If you're operator, specify AzureStackAdmin . |
L'endpoint di Resource ManagerResource Manager endpoint |
https://management.contoso.onmicrosoft.com |
Il ResourceManagerUrl in Gabriele è: https://management.local.azurestack.external/ il ResourceManagerUrl in sistemi integrati è: in https://management.<region>.<fqdn>/ caso di domande sull'endpoint di sistema integrato, contattare l'operatore cloud.The ResourceManagerUrl in the ASDK is: https://management.local.azurestack.external/ The ResourceManagerUrl in integrated systems is: https://management.<region>.<fqdn>/ If you have a question about the integrated system endpoint, contact your cloud operator. |
Endpoint di archiviazioneStorage endpoint |
local.contoso.onmicrosoft.comlocal.contoso.onmicrosoft.com |
local.azurestack.external è per Gabriele.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Suffisso dell'insieme di credenziali delle credenzialiKeyvault suffix |
. vault.contoso.onmicrosoft.com.vault.contoso.onmicrosoft.com |
.vault.local.azurestack.external è per Gabriele..vault.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
ID risorsa grafico endpoint Active DirectoryEndpoint active directory graph resource ID |
https://graph.windows.net/ |
ID risorsa di Active Directory.The Active Directory resource ID. |
az cloud register `
-n <environmentname> `
--endpoint-resource-manager "https://management.<region>.<fqdn>" `
--suffix-storage-endpoint "<fqdn>" `
--suffix-keyvault-dns ".vault.<fqdn>" `
--endpoint-active-directory-graph-resource-id "https://graph.windows.net/"
È possibile trovare un riferimento per il comando Register nella documentazione di riferimento dell'interfaccia della riga di comando di Azure.You can find a reference for the register command in the Azure CLI reference documentation.
Per impostare l'ambiente attivo, usare i comandi seguenti.Set the active environment by using the following commands.
az cloud set -n <environmentname>
Aggiornare la configurazione dell'ambiente per usare il profilo della versione API specifica dell'hub Azure Stack.Update your environment configuration to use the Azure Stack Hub specific API version profile. Per aggiornare la configurazione, eseguire il comando seguente:To update the configuration, run the following command:
az cloud update --profile 2019-03-01-hybrid
Accedere all'ambiente di Azure Stack hub usando il az login
comando.Sign in to your Azure Stack Hub environment by using the az login
command.
È possibile accedere all'ambiente di Azure Stack hub usando le credenziali utente o con un' entità servizio (SPN) fornita dall'operatore cloud.You can sign in to the Azure Stack Hub environment using your user credentials, or with a service principal (SPN) provided to you by your cloud operator.
Accedere come utente:Sign in as a user:
È possibile specificare il nome utente e una password direttamente all'interno del comando az login
oppure eseguire l'autenticazione tramite un browser.You can either specify the username and password directly within the az login
command, or authenticate by using a browser. È necessario eseguire quest'ultimo se per l'account è abilitata l'autenticazione a più fattori:You must do the latter if your account has multi-factor authentication enabled:
az login -u "user@contoso.onmicrosoft.com" -p 'Password123!' --tenant contoso.onmicrosoft.com
Nota
Se per l'account utente è abilitata l'autenticazione a più fattori, usare il az login
comando senza fornire il -u
parametro.If your user account has multi-factor authentication enabled, use the az login
command without providing the -u
parameter. L'esecuzione di questo comando fornisce un URL e un codice che è necessario usare per l'autenticazione.Running this command gives you a URL and a code that you must use to authenticate.
Accedere come entità servizio:Sign in as a service principal:
Prima di eseguire l'accesso, creare un'entità servizio tramite l'portale di Azure o l'interfaccia della riga di comando e assegnarle un ruolo.Before you sign in, create a service principal through the Azure portal or CLI and assign it a role. A questo punto, accedere usando il comando seguente:Now, sign in by using the following command:
az login `
--tenant <Azure Active Directory Tenant name. `
For example: myazurestack.onmicrosoft.com> `
--service-principal `
-u <Application Id of the Service Principal> `
-p <Key generated for the Service Principal>
Verificare che l'ambiente sia impostato correttamente e che l'ambiente sia attivo.Verify that your environment is set correctly and that your environment is the active cloud.
az cloud list --output table
Si noterà che l'ambiente è elencato e che è inattivo true
.You should see that your environment is listed and IsActive is true
. Ad esempio:For example:
IsActive Name Profile
---------- ----------------- -----------------
False AzureCloud 2019-03-01-hybrid
False AzureChinaCloud latest
False AzureUSGovernment latest
False AzureGermanCloud latest
True AzureStackUser 2019-03-01-hybrid
Testare la connettivitàTest the connectivity
Con tutti gli elementi impostati, usare l'interfaccia della riga di comando per creare risorse all'interno Azure Stack Hub.With everything set up, use CLI to create resources within Azure Stack Hub. Ad esempio, è possibile creare un gruppo di risorse per un'app e aggiungere una macchina virtuale.For example, you can create a resource group for an app and add a VM. Usare il comando seguente per creare un gruppo di risorse denominato "MyResourceGroup":Use the following command to create a resource group named "MyResourceGroup":
az group create -n MyResourceGroup -l local
Se il gruppo di risorse viene creato correttamente, il comando precedente restituisce le seguenti proprietà della risorsa appena creata:If the resource group is created successfully, the previous command outputs the following properties of the newly created resource:

Questa sezione illustra la configurazione dell'interfaccia della riga di comando se si usa Active Directory servizi federati (AD FS) come servizio di gestione delle identità e si usa l'interfaccia della riga di comando in un computer Windows.This section walks you through setting up CLI if you're using Active Directory Federated Services (AD FS) as your identity management service, and are using CLI on a Windows machine.
Connettersi all'hub Azure StackConnect to Azure Stack Hub
Se si usa Gabriele, considerare attendibile il certificato radice CA dell'hub Azure Stack.If you are using the ASDK, trust the Azure Stack Hub CA root certificate. Per istruzioni, vedere attendibilità del certificato.For instruction, see Trust the certificate.
Registrare l'ambiente dell'hub Azure Stack eseguendo il az cloud register
comando.Register your Azure Stack Hub environment by running the az cloud register
command.
Registrare l'ambiente.Register your environment. Quando si esegue, usare i parametri seguenti az cloud register
:Use the following parameters when running az cloud register
:
ValoreValue |
EsempioExample |
DescrizioneDescription |
Nome ambienteEnvironment name |
AzureStackUserAzureStackUser |
Usare AzureStackUser per l'ambiente utente.Use AzureStackUser for the user environment. Se si è operatore, specificare AzureStackAdmin .If you're operator, specify AzureStackAdmin . |
L'endpoint di Resource ManagerResource Manager endpoint |
https://management.local.azurestack.external |
Il ResourceManagerUrl in Gabriele è: https://management.local.azurestack.external/ il ResourceManagerUrl in sistemi integrati è: in https://management.<region>.<fqdn>/ caso di domande sull'endpoint di sistema integrato, contattare l'operatore cloud.The ResourceManagerUrl in the ASDK is: https://management.local.azurestack.external/ The ResourceManagerUrl in integrated systems is: https://management.<region>.<fqdn>/ If you have a question about the integrated system endpoint, contact your cloud operator. |
Endpoint di archiviazioneStorage endpoint |
local. azurestack. Externallocal.azurestack.external |
local.azurestack.external è per Gabriele.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Suffisso dell'insieme di credenziali delle credenzialiKeyvault suffix |
. Vault. local. azurestack. External.vault.local.azurestack.external |
.vault.local.azurestack.external è per Gabriele..vault.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Endpoint doc alias immagine VM-VM image alias doc endpoint- |
https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json |
URI del documento, che contiene gli alias delle immagini della macchina virtuale.URI of the document, which contains VM image aliases. Per ulteriori informazioni, vedere la pagina relativa alla configurazione dell'endpoint alias della macchina virtuale.For more info, see Set up the virtual machine alias endpoint. |
az cloud register -n <environmentname> --endpoint-resource-manager "https://management.local.azurestack.external" --suffix-storage-endpoint "local.azurestack.external" --suffix-keyvault-dns ".vault.local.azurestack.external" --endpoint-vm-image-alias-doc <URI of the document which contains VM image aliases>
Per impostare l'ambiente attivo, usare i comandi seguenti.Set the active environment by using the following commands.
az cloud set -n <environmentname>
Aggiornare la configurazione dell'ambiente per usare il profilo della versione API specifica dell'hub Azure Stack.Update your environment configuration to use the Azure Stack Hub specific API version profile. Per aggiornare la configurazione, eseguire il comando seguente:To update the configuration, run the following command:
az cloud update --profile 2019-03-01-hybrid
Nota
Se si esegue una versione di Azure Stack Hub prima della compilazione 1808, è necessario usare il profilo di versione dell'API 2017-03-09-profile anziché il profilo di versione dell'API 2019-03-01-Hybrid.If you're running a version of Azure Stack Hub before the 1808 build, you must use the API version profile 2017-03-09-profile rather than the API version profile 2019-03-01-hybrid. È anche necessario usare una versione recente dell'interfaccia della riga di comando di Azure.You also need to use a recent version of the Azure CLI.
Accedere all'ambiente di Azure Stack hub usando il az login
comando.Sign in to your Azure Stack Hub environment by using the az login
command. È possibile accedere all'ambiente di Azure Stack hub sia come utente che come entità servizio.You can sign in to the Azure Stack Hub environment either as a user or as a service principal.
Accedere come utente:Sign in as a user:
È possibile specificare il nome utente e una password direttamente all'interno del comando az login
oppure eseguire l'autenticazione tramite un browser.You can either specify the username and password directly within the az login
command, or authenticate by using a browser. È necessario eseguire quest'ultimo se per l'account è abilitata l'autenticazione a più fattori:You must do the latter if your account has multi-factor authentication enabled:
az cloud register -n <environmentname> --endpoint-resource-manager "https://management.local.azurestack.external" --suffix-storage-endpoint "local.azurestack.external" --suffix-keyvault-dns ".vault.local.azurestack.external" --endpoint-vm-image-alias-doc <URI of the document which contains VM image aliases> --profile "2019-03-01-hybrid"
Nota
Se per l'account utente è abilitata l'autenticazione a più fattori, usare il az login
comando senza fornire il -u
parametro.If your user account has multi-factor authentication enabled, use the az login
command without providing the -u
parameter. L'esecuzione di questo comando fornisce un URL e un codice che è necessario usare per l'autenticazione.Running this command gives you a URL and a code that you must use to authenticate.
Accedere come entità servizio:Sign in as a service principal:
Preparare il file con estensione PEM da usare per l'accesso all'entità servizio.Prepare the .pem file to be used for service principal login.
Nel computer client in cui è stata creata l'entità, esportare il certificato dell'entità servizio come PFX con la chiave privata che si trova in cert:\CurrentUser\My
.On the client machine where the principal was created, export the service principal certificate as a pfx with the private key located at cert:\CurrentUser\My
. Il nome del certificato ha lo stesso nome dell'entità.The cert name has the same name as the principal.
Convertire il file pfx in PEM (usare l'utilità OpenSSL).Convert the pfx to pem (use the OpenSSL utility).
Accedere all'interfaccia della riga di comando:Sign in to the CLI:
az login --service-principal \
-u <Client ID from the Service Principal details> \
-p <Certificate's fully qualified name, such as, C:\certs\spn.pem>
--tenant <Tenant ID> \
--debug
Testare la connettivitàTest the connectivity
Con tutti gli elementi impostati, usare l'interfaccia della riga di comando per creare risorse all'interno Azure Stack Hub.With everything set up, use CLI to create resources within Azure Stack Hub. Ad esempio, è possibile creare un gruppo di risorse per un'app e aggiungere una macchina virtuale.For example, you can create a resource group for an app and add a VM. Usare il comando seguente per creare un gruppo di risorse denominato "MyResourceGroup":Use the following command to create a resource group named "MyResourceGroup":
az group create -n MyResourceGroup -l local
Se il gruppo di risorse viene creato correttamente, il comando precedente restituisce le seguenti proprietà della risorsa appena creata:If the resource group is created successfully, the previous command outputs the following properties of the newly created resource:

Questa sezione illustra la configurazione dell'interfaccia della riga di comando se si usa Azure AD come servizio di gestione delle identità e si usa l'interfaccia della riga di comando in un computer Linux.This section walks you through setting up CLI if you're using Azure AD as your identity management service, and are using CLI on a Linux machine.
Connettersi all'hub Azure StackConnect to Azure Stack Hub
Usare la procedura seguente per connettersi a Azure Stack Hub:Use the following steps to connect to Azure Stack Hub:
Se si usa Gabriele, considerare attendibile il certificato radice CA dell'hub Azure Stack.If you are using the ASDK, trust the Azure Stack Hub CA root certificate. Per istruzioni, vedere attendibilità del certificato.For instruction, see Trust the certificate.
Registrare l'ambiente dell'hub Azure Stack eseguendo il az cloud register
comando.Register your Azure Stack Hub environment by running the az cloud register
command.
Registrare l'ambiente.Register your environment. Quando si esegue, usare i parametri seguenti az cloud register
:Use the following parameters when running az cloud register
:
ValoreValue |
EsempioExample |
DescrizioneDescription |
Nome ambienteEnvironment name |
AzureStackUserAzureStackUser |
Usare AzureStackUser per l'ambiente utente.Use AzureStackUser for the user environment. Se si è operatore, specificare AzureStackAdmin .If you're operator, specify AzureStackAdmin . |
L'endpoint di Resource ManagerResource Manager endpoint |
https://management.local.azurestack.external |
Il ResourceManagerUrl in Gabriele è: https://management.local.azurestack.external/ il ResourceManagerUrl in sistemi integrati è: in https://management.<region>.<fqdn>/ caso di domande sull'endpoint di sistema integrato, contattare l'operatore cloud.The ResourceManagerUrl in the ASDK is: https://management.local.azurestack.external/ The ResourceManagerUrl in integrated systems is: https://management.<region>.<fqdn>/ If you have a question about the integrated system endpoint, contact your cloud operator. |
Endpoint di archiviazioneStorage endpoint |
local. azurestack. Externallocal.azurestack.external |
local.azurestack.external è per Gabriele.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Suffisso dell'insieme di credenziali delle credenzialiKeyvault suffix |
. Vault. local. azurestack. External.vault.local.azurestack.external |
.vault.local.azurestack.external è per Gabriele..vault.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Endpoint doc alias immagine VM-VM image alias doc endpoint- |
https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json |
URI del documento, che contiene gli alias delle immagini della macchina virtuale.URI of the document, which contains VM image aliases. Per ulteriori informazioni, vedere la pagina relativa alla configurazione dell'endpoint alias della macchina virtuale.For more info, see Set up the virtual machine alias endpoint. |
az cloud register -n <environmentname> --endpoint-resource-manager "https://management.local.azurestack.external" --suffix-storage-endpoint "local.azurestack.external" --suffix-keyvault-dns ".vault.local.azurestack.external" --endpoint-vm-image-alias-doc <URI of the document which contains VM image aliases>
Impostare l'ambiente attivo.Set the active environment.
az cloud set -n <environmentname>
Aggiornare la configurazione dell'ambiente per usare il profilo della versione API specifica dell'hub Azure Stack.Update your environment configuration to use the Azure Stack Hub specific API version profile. Per aggiornare la configurazione, eseguire il comando seguente:To update the configuration, run the following command:
az cloud update --profile 2019-03-01-hybrid
Nota
Se si esegue una versione di Azure Stack Hub prima della compilazione 1808, è necessario usare il profilo di versione dell'API 2017-03-09-profile anziché il profilo di versione dell'API 2019-03-01-Hybrid.If you're running a version of Azure Stack Hub before the 1808 build, you must use the API version profile 2017-03-09-profile rather than the API version profile 2019-03-01-hybrid. È anche necessario usare una versione recente dell'interfaccia della riga di comando di Azure.You also need to use a recent version of the Azure CLI.
Accedere all'ambiente di Azure Stack hub usando il az login
comando.Sign in to your Azure Stack Hub environment by using the az login
command. È possibile accedere all'ambiente di Azure Stack hub sia come utente che come entità servizio.You can sign in to the Azure Stack Hub environment either as a user or as a service principal.
Accedere come utente:Sign in as a user:
È possibile specificare il nome utente e una password direttamente all'interno del comando az login
oppure eseguire l'autenticazione tramite un browser.You can either specify the username and password directly within the az login
command, or authenticate by using a browser. È necessario eseguire quest'ultimo se per l'account è abilitata l'autenticazione a più fattori:You must do the latter if your account has multi-factor authentication enabled:
az login \
-u <Active directory global administrator or user account. For example: username@<aadtenant>.onmicrosoft.com> \
--tenant <Azure Active Directory Tenant name. For example: myazurestack.onmicrosoft.com>
Nota
Se per l'account utente è abilitata l'autenticazione a più fattori, è possibile usare il az login
comando senza fornire il -u
parametro.If your user account has multi-factor authentication enabled, you can use the az login
command without providing the -u
parameter. L'esecuzione di questo comando fornisce un URL e un codice che è necessario usare per l'autenticazione.Running this command gives you a URL and a code that you must use to authenticate.
Accedere come entità servizioSign in as a service principal
Prima di eseguire l'accesso, creare un'entità servizio tramite l'portale di Azure o l'interfaccia della riga di comando e assegnarle un ruolo.Before you sign in, create a service principal through the Azure portal or CLI and assign it a role. A questo punto, accedere usando il comando seguente:Now, sign in by using the following command:
az login \
--tenant <Azure Active Directory Tenant name. For example: myazurestack.onmicrosoft.com> \
--service-principal \
-u <Application Id of the Service Principal> \
-p <Key generated for the Service Principal>
Testare la connettivitàTest the connectivity
Con tutti gli elementi impostati, usare l'interfaccia della riga di comando per creare risorse all'interno Azure Stack Hub.With everything set up, use CLI to create resources within Azure Stack Hub. Ad esempio, è possibile creare un gruppo di risorse per un'app e aggiungere una macchina virtuale.For example, you can create a resource group for an app and add a VM. Usare il comando seguente per creare un gruppo di risorse denominato "MyResourceGroup":Use the following command to create a resource group named "MyResourceGroup":
az group create -n MyResourceGroup -l local
Se il gruppo di risorse viene creato correttamente, il comando precedente restituisce le seguenti proprietà della risorsa appena creata:If the resource group is created successfully, the previous command outputs the following properties of the newly created resource:

Questa sezione illustra la configurazione dell'interfaccia della riga di comando se si usa Active Directory servizi federati (AD FS) come servizio di gestione e si usa l'interfaccia della riga di comando in un computer Linux.This section walks you through setting up CLI if you're using Active Directory Federated Services (AD FS) as your management service, and are using CLI on a Linux machine.
Connettersi all'hub Azure StackConnect to Azure Stack Hub
Usare la procedura seguente per connettersi a Azure Stack Hub:Use the following steps to connect to Azure Stack Hub:
Se si usa Gabriele, considerare attendibile il certificato radice CA dell'hub Azure Stack.If you are using the ASDK, trust the Azure Stack Hub CA root certificate. Per istruzioni, vedere attendibilità del certificato.For instruction, see Trust the certificate.
Registrare l'ambiente dell'hub Azure Stack eseguendo il az cloud register
comando.Register your Azure Stack Hub environment by running the az cloud register
command.
Registrare l'ambiente.Register your environment. Usare i parametri seguenti durante l'esecuzione di az cloud register
.Use the following parameters when running az cloud register
.
ValoreValue |
EsempioExample |
DescrizioneDescription |
Nome ambienteEnvironment name |
AzureStackUserAzureStackUser |
Usare AzureStackUser per l'ambiente utente.Use AzureStackUser for the user environment. Se si è operatore, specificare AzureStackAdmin .If you're operator, specify AzureStackAdmin . |
L'endpoint di Resource ManagerResource Manager endpoint |
https://management.local.azurestack.external |
Il ResourceManagerUrl in Gabriele è: https://management.local.azurestack.external/ il ResourceManagerUrl in sistemi integrati è: in https://management.<region>.<fqdn>/ caso di domande sull'endpoint di sistema integrato, contattare l'operatore cloud.The ResourceManagerUrl in the ASDK is: https://management.local.azurestack.external/ The ResourceManagerUrl in integrated systems is: https://management.<region>.<fqdn>/ If you have a question about the integrated system endpoint, contact your cloud operator. |
Endpoint di archiviazioneStorage endpoint |
local. azurestack. Externallocal.azurestack.external |
local.azurestack.external è per Gabriele.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Suffisso dell'insieme di credenziali delle credenzialiKeyvault suffix |
. Vault. local. azurestack. External.vault.local.azurestack.external |
.vault.local.azurestack.external è per Gabriele..vault.local.azurestack.external is for the ASDK. Per un sistema integrato, usare un endpoint per il sistema.For an integrated system, use an endpoint for your system. |
Endpoint doc alias immagine VM-VM image alias doc endpoint- |
https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json |
URI del documento, che contiene gli alias delle immagini della macchina virtuale.URI of the document, which contains VM image aliases. Per ulteriori informazioni, vedere la pagina relativa alla configurazione dell'endpoint alias della macchina virtuale.For more info, see Set up the virtual machine alias endpoint. |
az cloud register -n <environmentname> --endpoint-resource-manager "https://management.local.azurestack.external" --suffix-storage-endpoint "local.azurestack.external" --suffix-keyvault-dns ".vault.local.azurestack.external" --endpoint-vm-image-alias-doc <URI of the document which contains VM image aliases>
Impostare l'ambiente attivo.Set the active environment.
az cloud set -n <environmentname>
Aggiornare la configurazione dell'ambiente per usare il profilo della versione API specifica dell'hub Azure Stack.Update your environment configuration to use the Azure Stack Hub specific API version profile. Per aggiornare la configurazione, eseguire il comando seguente:To update the configuration, run the following command:
az cloud update --profile 2019-03-01-hybrid
Nota
Se si esegue una versione di Azure Stack Hub prima della compilazione 1808, è necessario usare il profilo di versione dell'API 2017-03-09-profile anziché il profilo di versione dell'API 2019-03-01-Hybrid.If you're running a version of Azure Stack Hub before the 1808 build, you must use the API version profile 2017-03-09-profile rather than the API version profile 2019-03-01-hybrid. È anche necessario usare una versione recente dell'interfaccia della riga di comando di Azure.You also need to use a recent version of the Azure CLI.
Accedere all'ambiente di Azure Stack hub usando il az login
comando.Sign in to your Azure Stack Hub environment by using the az login
command. È possibile accedere all'ambiente di Azure Stack hub sia come utente che come entità servizio.You can sign in to the Azure Stack Hub environment either as a user or as a service principal.
Accedi:Sign in:
- Come utente che usa un Web browser con un codice dispositivo:As a user using a web browser with a device code:
az login --use-device-code
Nota
L'esecuzione del comando fornisce un URL e un codice che è necessario usare per l'autenticazione.Running the command gives you a URL and a code that you must use to authenticate.
Come entità servizio:As a service principal:
Preparare il file con estensione PEM da usare per l'accesso all'entità servizio.Prepare the .pem file to be used for service principal login.
Nel computer client in cui è stata creata l'entità, esportare il certificato dell'entità servizio come PFX con la chiave privata che si trova in cert:\CurrentUser\My
.On the client machine where the principal was created, export the service principal certificate as a pfx with the private key located at cert:\CurrentUser\My
. Il nome del certificato ha lo stesso nome dell'entità.The cert name has the same name as the principal.
Convertire il file pfx in PEM (usare l'utilità OpenSSL).Convert the pfx to pem (use the OpenSSL utility).
Accedere all'interfaccia della riga di comando:Sign in to the CLI:
az login --service-principal \
-u <Client ID from the Service Principal details> \
-p <Certificate's fully qualified name, such as, C:\certs\spn.pem>
--tenant <Tenant ID> \
--debug
Testare la connettivitàTest the connectivity
Con tutti gli elementi impostati, usare l'interfaccia della riga di comando per creare risorse all'interno Azure Stack Hub.With everything set up, use CLI to create resources within Azure Stack Hub. Ad esempio, è possibile creare un gruppo di risorse per un'app e aggiungere una macchina virtuale.For example, you can create a resource group for an app and add a VM. Usare il comando seguente per creare un gruppo di risorse denominato "MyResourceGroup":Use the following command to create a resource group named "MyResourceGroup":
az group create -n MyResourceGroup -l local
Se il gruppo di risorse viene creato correttamente, il comando precedente restituisce le seguenti proprietà della risorsa appena creata:If the resource group is created successfully, the previous command outputs the following properties of the newly created resource:

Problemi notiKnown issues
Si verificano problemi noti quando si usa l'interfaccia della riga di comando nell'hub Azure Stack:There are known issues when using CLI in Azure Stack Hub:
- Modalità interattiva dell'interfaccia della riga di comando.The CLI interactive mode. Ad esempio, il
az interactive
comando non è ancora supportato nell'Hub Azure stack.For example, the az interactive
command, isn't yet supported in Azure Stack Hub.
- Per ottenere l'elenco delle immagini di macchina virtuale disponibili nell'hub Azure Stack, usare il
az vm image list --all
comando anziché il az vm image list
comando.To get the list of VM images available in Azure Stack Hub, use the az vm image list --all
command instead of the az vm image list
command. Specificando l' --all
opzione si garantisce che la risposta restituisca solo le immagini disponibili nell'ambiente dell'Hub Azure stack.Specifying the --all
option ensures that the response returns only the images that are available in your Azure Stack Hub environment.
- Gli alias di immagini di macchina virtuale disponibili in Azure potrebbero non essere applicabili all'hub Azure Stack.VM image aliases that are available in Azure may not be applicable to Azure Stack Hub. Quando si usano le immagini di VM, è necessario usare l'intero parametro URN (Canonical: UbuntuServer: 14.04.3-LTS: 1.0.0) anziché l'alias dell'immagine.When using VM images, you must use the entire URN parameter (Canonical:UbuntuServer:14.04.3-LTS:1.0.0) instead of the image alias. Questo URN deve corrispondere alle specifiche dell'immagine derivate dal
az vm images list
comando.This URN must match the image specifications as derived from the az vm images list
command.