Ansluta till Azure Stack hubb med PowerShell som en användareConnect to Azure Stack Hub with PowerShell as a user
Du kan ansluta till Azure Stack hubb med PowerShell för att hantera Azure Stack Hub-resurser.You can connect to Azure Stack Hub with PowerShell to manage Azure Stack Hub resources. Du kan till exempel använda PowerShell för att prenumerera på erbjudanden, skapa virtuella datorer (VM) och Distribuera Azure Resource Manager mallar.For example, you can use PowerShell to subscribe to offers, create virtual machines (VMs), and deploy Azure Resource Manager templates.
Så här hämtar du installationen:To get setup:
- Kontrol lera att du har kraven.Make sure you have the requirements.
- Anslut till Azure Active Directory (Azure AD) eller Active Directory Federation Services (AD FS) (AD FS).Connect with Azure Active Directory (Azure AD) or Active Directory Federation Services (AD FS).
- Registrera resurs leverantörer.Register resource providers.
- Testa din anslutning.Test your connectivity.
Krav för att ansluta med PowerShellPrerequisites to connecting with PowerShell
Konfigurera de här förutsättningarna från utvecklings paketeteller från en Windows-baserad extern klient om du är ansluten via VPN:Configure these prerequisites from the development kit, or from a Windows-based external client if you're connected through VPN:
- Installera Azure Stack Hub-kompatibla Azure PowerShell-moduler.Install Azure Stack Hub-compatible Azure PowerShell modules.
- Ladda ned de verktyg som krävs för att arbeta med Azure Stack Hub.Download the tools required to work with Azure Stack Hub.
Se till att du ersätter följande skript-variabler med värden från Azure Stack Hub-konfigurationen:Make sure you replace the following script variables with values from your Azure Stack Hub configuration:
- Namn på Azure AD-klientAzure AD tenant name
Namnet på din Azure AD-klient som används för att hantera Azure Stack Hub.The name of your Azure AD tenant used to manage Azure Stack Hub. Till exempel yourdirectory.onmicrosoft.com.For example, yourdirectory.onmicrosoft.com. - Azure Resource Manager slut punktAzure Resource Manager endpoint
För Azure Stack Development Kit är det här värdet inställt påhttps://management.local.azurestack.external
.For Azure Stack Development kit, this value is set tohttps://management.local.azurestack.external
. Kontakta tjänst leverantören för att få det här värdet för integrerade system för Azure Stack Hub.To get this value for Azure Stack Hub integrated systems, contact your service provider.
Ansluta till Azure Stack hubb med Azure ADConnect to Azure Stack Hub with Azure AD
Add-AzEnvironment -Name "AzureStackUser" -ArmEndpoint "https://management.local.azurestack.external"
# Set your tenant name
$AuthEndpoint = (Get-AzEnvironment -Name "AzureStackUser").ActiveDirectoryAuthority.TrimEnd('/')
$AADTenantName = "<myDirectoryTenantName>.onmicrosoft.com"
$TenantId = (invoke-restmethod "$($AuthEndpoint)/$($AADTenantName)/.well-known/openid-configuration").issuer.TrimEnd('/').Split('/')[-1]
# After signing in to your environment, Azure Stack Hub cmdlets
# can be easily targeted at your Azure Stack Hub instance.
Connect-AzAccount -EnvironmentName "AzureStackUser" -TenantId $TenantId
Anslut till Azure Stack hubb med AD FSConnect to Azure Stack Hub with AD FS
# Register an Azure Resource Manager environment that targets your Azure Stack Hub instance
Add-AzEnvironment -Name "AzureStackUser" -ArmEndpoint "https://management.local.azurestack.external"
# Sign in to your environment
Connect-AzAccount -EnvironmentName "AzureStackUser"
Registrera resurs leverantörerRegister resource providers
Resurs leverantörer registreras inte automatiskt för nya användar prenumerationer som inte har några resurser som distribueras via portalen.Resource providers aren't automatically registered for new user subscriptions that don't have any resources deployed through the portal. Du kan uttryckligen registrera en resurs leverantör genom att köra följande skript:You can explicitly register a resource provider by running the following script:
foreach($s in (Get-AzSubscription)) {
Select-AzSubscription -SubscriptionId $s.SubscriptionId | Out-Null
Write-Progress $($s.SubscriptionId + " : " + $s.SubscriptionName)
Get-AzResourceProvider -ListAvailable | Register-AzResourceProvider
}
Anteckning
AD FS stöder endast interaktiv autentisering med användar identiteter.AD FS only supports interactive authentication with user identities. Om det krävs ett Credential-objekt måste du använda ett tjänst huvud namn (SPN).If a credential object is required, you must use a service principal (SPN). Mer information om hur du konfigurerar ett huvud namn för tjänsten med Azure Stack hubb och AD FS som identitets hanterings tjänst finns i hantera en AD FS app-identitet.For more information on setting up a service principal with Azure Stack Hub and AD FS as your identity management service, see Manage an AD FS app identity.
Testa anslutningenTest the connectivity
När du har konfigurerat allt måste du testa anslutningen med hjälp av PowerShell för att skapa resurser i Azure Stack Hub.When you've got everything setup, test connectivity by using PowerShell to create resources in Azure Stack Hub. Skapa en resurs grupp för ett program och Lägg till en virtuell dator som ett test.As a test, create a resource group for an application and add a VM. Kör följande kommando för att skapa en resurs grupp med namnet "MyResourceGroup":Run the following command to create a resource group named "MyResourceGroup":
New-AzResourceGroup -Name "MyResourceGroup" -Location "Local"
Nästa stegNext steps
- Utveckla mallar för Azure Stack hubbDevelop templates for Azure Stack Hub
- Distribuera mallar med PowerShellDeploy templates with PowerShell
- Referens för Azure Stack Hub PowerShell-modulAzure Stack Hub PowerShell Module Reference
- Om du vill konfigurera PowerShell för moln operatörs miljön läser du artikeln Konfigurera den Azure Stack Hub-operatörens PowerShell-miljö .If you want to set up PowerShell for the cloud operator environment, refer to the Configure the Azure Stack Hub operator's PowerShell environment article.