AzureStack-Tools/Registration
Rakesh Kumar e1b80b24b3 Add back UsageReportingEnabled and MarketplaceSyndicationEnabled parameters to Get-AzsRegistrationToken 2021-10-18 14:01:45 -07:00
..
README.md Adding support for consent in enable remote management script (#588) 2020-12-04 12:01:29 -08:00
RegisterWithAzure.psm1 Add back UsageReportingEnabled and MarketplaceSyndicationEnabled parameters to Get-AzsRegistrationToken 2021-10-18 14:01:45 -07:00
RegistrationUtilities.psm1 add optional registration naming; usage reporting default to enabled 2018-07-19 13:34:29 -07:00
RemoteManagement.psm1 Adding support for consent in enable remote management script (#588) 2020-12-04 12:01:29 -08:00

README.md

Registration

The functions in this module allow you to perform the steps of registering your Azure Stack with your Azure subscription. Additional details can be found in the documentation.

Prerequisites

  • You must install the correct version of Azure Powershell, and download the Azure Stack tools
  • The registration functions must be run on a machine that has access to the Privileged Endpoint.
  • You must have access to an Azure subscription, and your Azure account must be an Owner of the subscription.
  • Open an elevated instance of Powershell ISE (ie: Run as Administrator).

Import RegisterWithAzure.psm1

To import the RegisterWithAzure.psm1 module, navigate to where the module was downloaded (typically C:\AzureStack-Tools-master\Registration) and run the below:

Import-Module .\RegisterWithAzure.psm1 -Force -Verbose

Register in a connected environment

In a connected environment, to register with Azure, allow the download of marketplace items, and start reporting usage data to Azure you must be logged in to the correct Azure Powershell context

Set the correct Azure Powershell Context

Login-AzureRmAccount -Subscription '<Your Azure Subscription>' -Environment '<The Azure Environment where subscription was created>'

Complete registration / activation

Then you must run the below command from RegisterWithAzure.psm1:

Set-AzsRegistration -PrivilegedEndpoint "<Computer Name>-ERCS01" -BillingModel PayAsYouUse

The process takes between 10 and 15 minutes.

Registration with usage reporting or marketplace syndication disabled

# usage reporting and marketplace syndication are enabled by default, to disable use the below command
# with disabled usage reporting
Set-AzsRegistration -PrivilegedEndpoint "<Computer Name>-ERCS01" -BillingModel PayAsYouUse -UsageReportingEnabled:$false
# with disabled marketplace syndication
Set-AzsRegistration -PrivilegedEndpoint "<Computer Name>-ERCS01" -BillingModel PayAsYouUse -MarketplaceSyndicationEnabled:$false

Re-Register in a connected environment

In a connected environment, to re-register with Azure using the existing registration details, set the correct Azure PowerShell context using the subscription used during the existing registration.

Set the correct Azure Powershell Context

Login-AzureRmAccount -Subscription '<Your Azure Subscription used during existing registration>' -Environment '<The Azure Environment where subscription was created>'

Re-Registration

Then you must run the below command from RegisterWithAzure.psm1:

# $PrivilegedEndpointCredential - credential to access PrivilegedEndpoint
# $AzureStackAdminCredential - Azure Stack admin credential used to access admin portal resources
Set-AzsRegistration -PrivilegedEndpointCredential $PrivilegedEndpointCredential -PrivilegedEndpoint "<Computer Name>-ERCS01" -AzureStackAdminCredential $AzureStackAdminCredential -Reregister

The process takes between 10 and 15 minutes.

Change or remove registration in a connected environment

Remove Registration

To remove the existing registration resource and disable marketplace syndication and usage data reporting. While running Remove-AzsRegistration, you must be signed in to the subscription used during the registration and use values of the RegistrationName and ResourceGroupName parameters as shown in the administrator portal Find current registration details:

Remove-AzsRegistration -PrivilegedEndpoint "<Computer Name>-ERCS01" -RegistrationName '<Registration name from portal>' -ResourceGroupName '<Registration resource group from portal>'

[!NOTE] You must be logged in to the same Azure Powershell context that you ran Set-AzsRegistration under. The process takes between 10 and 15 minutes.

Switch registration to a new subscription

To switch the existing registration to a new subscription or directory, first remove the existing registration (Remove Registration) and then run below cmds:

# Set the Azure Powershell context to the appropriate subscription
Set-AzureRmContext -SubscriptionId "<new subscription to register>"
# Register with the new subscription
Set-AzsRegistration -PrivilegedEndpoint "<Computer Name>-ERCS01" -BillingModel PayAsYouUse

Register in a disconnected environment

If you are registering in an internet-disconnected scenario there are a few more steps to complete registration.

  1. Get registration token from Azure Stack
  2. Create registration resource in Azure
  3. Retrieve activation token from registration resource in Azure
  4. Create activation resource in Azure stack

Get a registration token

You must first retrieve a registration token from the Azure Stack environment

# Retrieve a registration token and save it to the TokenOutputFilePath
$TokenOutputFilePath = "<file path where token will be saved>"
Get-AzsRegistrationToken -PrivilegedEndpoint "<Computer Name>-ERCS01" -BillingModel Capacity -AgreementNumber '<EA Agreement Number>' -TokenOutputFilePath $TokenOutputFilepath

Create a registration resource in Azure

You must use the registration token created in the step above and perform the below command on a computer connected to public Azure [!NOTE] Remember to download and import the RegisterWithAzure.psm1 module before running the below commands

# Log in to the correct Azure Powershell context
Login-AzureRmAccount -Subscription '<Your Azure Subscription>' -Environment '<The Azure Environment where subscription was created>'
# Create a registration resource in Azure
Register-AzsEnvironment -RegistrationToken "<Registration token text value>"

Retrieve activation key

An activation key is required to create an activation resource in Azure Stack. You can retrieve this from the registration resource in Azure. Run the below command under the same context as the step above:

$KeyOutputFilePath = "<file path where key will be saved>"
Get-AzsActivationKey -RegistrationName "<name of registration resource in Azure>" -KeyOutputFilePath $KeyOutputFilePath

Create activation resource in Azure Stack

The activation key created above must be copied to the Azure Stack environment before registration / activation can be complete. Run the below commands to complete registration in a disconnected environment:

New-AzsActivationResource -PrivilegedEndpoint "<Computer Name>-ERCS01" -ActivationKey "<activation key text value>"

Registration and activation is now complete for a disconnected environment. If you need to change or update your registration in a disconnected environment follow the below instructions

Change or remove registration in a disconnected environment

Remove activation resource from Azure Stack

You must first remove the activation resource from your Azure Stack

Remove-AzsActivationResource -PrivilegedEndpoint "<Computer Name>-ERCS01"

Remove registration resource from Azure

Next you must remove the registration resource from Azure. The below command must be run on a computer with connection to public Azure and be logged in to the correct Azure Powershell context. You must provide either the registration token or the registration name to the below command:

# Use the registration name
UnRegister-AzsEnvironment -RegistrationName "<name of registration resource in Azure>"
# Or use the registration token
UnRegister-AzsEnvironment -RegistrationToken "<original registration token text value>"

Repeat the process for registering in a disconnected environment

Once the above steps are complete you must go through the steps for registering in a disconnected environment but you will need to update parameters on the registration token (if necessary) and ensure that commands performed on the public Azure connected machine are performed under the new Azure Powershell context.

Remote Management

The functions in this module allows to enable remote management on Azure Stack which are registered in connected mode. Additional details can be found in documentation. Note: Remote Management is only supported from AzureStack 2008 release onwards.

Prerequisites

  • Azure Stack already be registered with Azure. If its not registered then please follow registration steps described above.
  • Azure Stack is already registered in connected mode
  • You must have access to an Azure subscription with which Azure Stack is registered, and your Azure account must be an Owner/Contributor of that subscription.
  • Open an elevated instance of Powershell ISE (ie: Run as Administrator).
  • By running PowerShell command to enable the connection to the cloud you consent to the following:
    • Replication of Azure Stack Hub resource metadata for the purposes of managing Azure Stack Hub from Azure. For more details about the replicated data go here documentation.
    • Permission to allow only your approved operators the ability to control Azure Stack resources from the Azure portal.
    • Permission for Microsoft support to issue Support commands only during active support incidents, subject to an additional approval from you, to diagnose and resolve issues within your Azure Stack Hub infrastructure.

Import RemoteManagement.psm1

To import the RemoteManagement.psm1 module, navigate to where the module was downloaded (typically C:\AzureStack-Tools-master\Registration) and run the below:

Import-Module .\RemoteManagement.psm1 -Force -Verbose

Enable Remote Management

In a connected environment, to enable remote management you must be logged in to the correct Azure Powershell context

Set the correct Azure Powershell Context

Login-AzureRmAccount -Subscription '<Your Azure Subscription>' -Environment '<The Azure Environment where subscription was created>'

Initiate remote management enable

Then you must run the below command from RemoteManagement.psm1. You need to pass LinkedSubscription name - this is the name of resource created on your Azure subscription with which you can view replicated resources.

  • Note: Provide linked subcription name as name of resource you like to link your "Default Provider Subscription" on Azure. Example:"-DefaultProvider"
$name = "RedmondStack-DefaultProvider"
Enable-AzsCloudConnection -LinkedSubscriptionName $name -PrivilegedEndpoint "<Computer Name>-ERCS01" -ResourceGroupName "<Name-Of-ResourceGroup>"

The process takes between 10 and 15 minutes.