Showing posts with label Microsoft Azure. Show all posts
Showing posts with label Microsoft Azure. Show all posts

Monday, February 1, 2016

Free book! Cloud Consistency with Azure Resource Manager

Finally!

I was able to spend some wife points this weekend to finalize the new book “Cloud Consistency with Azure Resource Manager”.


This book is aiming to get you started with Azure Resource Manager and covers many examples on how to author templates, use functions as well as exploring many of the other aspects of Azure Resource Manager



Here’s a snapshot of the content:

Acknowledgements:
About the authors
Kristian Nese | @KristianNese
Flemming Riis | @FlemmingRiis
Background
Introduction
Microsoft Azure
Microsoft Azure Stack
Cloud Computing and Modern Application Modeling
Step 1 – Service Templates
Step 2 – VM Roles
Step 3 – Azure Resource Manager
Summary
IaaS v2 – Azure Resource Manager API replaces Service Management API
Consistent Management Layer
Azure PowerShell
Azure CLI
Azure Resource Manager Rest API
Azure Portal
Azure Resource Manager Templates
Deploying with Azure Resource Manager
Where can we deploy our Azure Resource Manager Templates
Explaining the template format
Authoring the first Azure Resource Manager Template
Adding parameter file
Visual Studio
PowerShell
Azure Portal
Idempotency with Azure Resource Manager
Resource Explorer
Imperative Deployment with Azure Resource Manager
Advanced Azure Resource Manager Templates
Functions
Extensions
Write once, deploy anywhere

Instead of jumping right into the authoring experience and learn how an ARM template is constructed, we wanted to give you enough context to know what’s going on in the industry, what is changing and how you should prepare yourself to take advantage of this new way of managing your cloud resoueces.

If you have been playing around with Azure already, you are probably very familiar with some of the content already. If you are new, and especially interested in Microsoft Azure Stack, you should be glad to know that everything you learn in this book can be addressed there as well.

It has been a great experience writing this book, covering some of the most interesting stuff we have available right now, and I have to emphasize that this book will also be updated as we move forward to keep up with all the great things that is happening in the Microsoft Cloud.


I really hope you enjoy it.

Friday, November 20, 2015

Getting started with VM Scale Sets with Azure Resource Manager

Recently, Microsoft announced the public preview of ‘VM Scale Sets’ which is a new Azure Compute resource (Microsoft.Compute/virtualMachineScaleSets) that lets customers deploy and manage a set of virtual machines that are identical.

Sounds familiar?

Yes, but at the same time, this is new. Let me explain why.

Azure Compute, Network and Storage serves as the backend for many familiar Azure Services that we are using already today, such as Web Apps, Batch, Azure Automation and much more.

You have probably also heard about the newly announced public preview of Service Fabric – which is the ideal platform for microservices and containerized workloads to ensure business continuity and reliable applications, completely changing the way customers can develop applications at hyper-scale.
But did you know that the Service Fabric is also a service that runs on top of a virtual machine, requires network connectivity using a “normal” network in Azure and also can use some of the storage features in the backend?

That is also where the VM Scale Sets can come into play, serving as the perfect foundation for those kind of services and applications you want to build.
VM Scale Sets are designed to support autoscale and doesn’t require any pre-provisioning of the virtual machines.

Network and storage features are of course incorporated as you would expect, so that you can easily leverage VM Scale Sets as a first class citizen in Azure, following the Resource Group structure you prefer.

I encourage you to take a closer look at VM Scale Sets, which is a new resource type within the Microsoft.Compute namespace for the CRP.

I have already created an Azure Resource Manager template that let you deploy VM Scale Sets – using DSC VM Extension to configure Web-Server (IIS), as well as deploying a virtual machine you can use for management.
There’s also additional details such as load balancing, network security groups and more that you can explore.





Have fun – and happy scaling!



Thursday, October 29, 2015

Azure Resource Manager – Deployment options

Hi all,

This is just a quick blog post to demonstrate how to provision an IaaS environment in Azure with the VM DSC extension to instantiate a new Web Server (IIS).

Say what?

You have probably seen many examples of this already, so I won’t try to sell you something new here.
However, I want to point out the difference of using an Azure Resource Manager template (.json, declarative) compared to using PowerShell – in an imperative way.

The reason for this blog post is the newly released AzureRM PowerShell module which introduces us to a new set of cmdlets (the downside here is that I am now forced to update the whitepaper… https://gallery.technet.microsoft.com/Cloud-Consistency-with-0b79b775 ).

Where we are coming from

Previously with the Service Management API, we normally created our virtual machines in a similar way to this:

$image = Get-AzureVMImage -ImageName "a699494373c04fc0bc8f2bb1389d6106__Windows-Server-2012-R2-201412.01-en.us-127GB.vhd"
$vnet = Get-AzureVNetSite
$vm = New-AzureVMConfig -Name $VMName -InstanceSize "Basic_A2" -ImageName $image.ImageName

### Deploy a new domain joined VM

$vm = Add-AzureProvisioningConfig -VM $vm -AdminUsername $username -Password $pwd -WindowsDomain -JoinDomain "azure.systemcenter365.com" -Domain "azure" -DomainUserName "knadm" -DomainPassword "superPWD" | Set-AzureSubnet -SubnetNames $vnet.subnets.name | Set-AzureStaticVNetIP -IPAddress "10.0.40.52"

New-AzureVM -VM $vm -Location "North Europe" -VNetName $vnet.name -ServiceName $ServiceName -Verbose -WaitForBoot

Also, if I wanted to add DSC to my VM using the Service Management API, I would have to do something like this:

# Fire and forget some DSC

$dscvm = Get-AzureVM -ServiceName $ServiceName -Name $VMName

Set-AzureVMDSCExtension -VM $dscvm -ConfigurationArchive "azureDSCDemo.ps1.zip" -ConfigurationName "tester" | Update-AzureVM

This has drastically changed with Azure Resource Manager, which introduces us to a new world with a lot of more opportunities (someone would also say more complexity).

Where we are going

In order to show you where we are heading with this, I would like to point you to my GitHub repo where you can find some learning examples on how this looks like by using Azure Resource Manager templates – but also the new AzureRM PowerShell module

ARM Template with a single-button deployment + PowerShell cmdlet for deployment


PowerShell script using the new AzureRM Module to create IaaS environment with DSC


Here’s the example using PowerShell:

# Connect to your Azure subscription

Add-AzureRmAccount -Credential (get-credential)

# Add some variables that you will use as you move forward

# Global

$RGname = "KNRGTest01"
$Location = "west europe"

# Storage

$StorageName = "Knstor5050"
$StorageType = "Standard_LRS"

# Network

$vnicName = "vmvNic"
$Subnet1Name = "Subnet1"
$vNetName = "KNVnet01"
$vNetAddressPrefix = "192.168.0.0/16"
$vNetSubnetAddressPrefix = "192.168.0.0/24"

# Compute

$VMName = "KNVM01"
$ComputerName = $VMName
$VMSize = "Standard_A2"
$OSDiskName = $VMName + "osDisk"

# Create a new Azure Resource Grou

$RG = New-AzureRmResourceGroup -Name $RGname -Location $location -Verbose

# Create Storage

$StorageAccount = New-AzureRmStorageAccount -ResourceGroupName $RGname -Name knstor5050 -Type $StorageType -Location $Location

# Create Network

$PIP = New-AzureRmPublicIpAddress -Name $vnicName -ResourceGroupName $RGname -Location $Location -AllocationMethod Dynamic
$SubnetConfig = New-AzureRmVirtualNetworkSubnetConfig -Name $Subnet1Name -AddressPrefix $vNetSubnetAddressPrefix
$vNET = New-AzureRmVirtualNetwork -Name $vNetName -ResourceGroupName $RGname -Location $Location -AddressPrefix $vNetAddressPrefix -Subnet $SubnetConfig
$Interface = New-AzureRmNetworkInterface -Name $vnicName -ResourceGroupName $RGname -Location $Location -SubnetId $vnet.Subnets[0].Id -PublicIpAddressId $pip.Id

# Create Compute

# Setup local VM object

$Credential = Get-Credential
$VirtualMachine = New-AzureRmVMConfig -VMName $VMName -VMSize $VMSize
$VirtualMachine = Set-AzureRmVMOperatingSystem -VM $VirtualMachine -Windows -ComputerName $ComputerName -Credential $credential -ProvisionVMAgent -EnableAutoUpdate
$VirtualMachine = Set-AzureRmVMSourceImage -VM $VirtualMachine -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-R2-Datacenter -Version "latest"
$VirtualMachine = Add-AzureRmVMNetworkInterface -VM $VirtualMachine -Id $interface.Id
$OSDiskUri = $StorageAccount.PrimaryEndpoints.Blob.ToString() + "vhds/" + $OSDiskName + ".vhd"
$VirtualMachine = Set-AzureRmVMOSDisk -VM $VirtualMachine -Name $OSDiskName -VhdUri $OSDiskUri -CreateOption fromImage

# Deploy the VM in Azure

New-AzureRmVM -ResourceGroupName $RGname -Location $Location -VM $VirtualMachine

# Publish DSC config to your newly created storage account

Publish-AzureRmVMDscConfiguration -ResourceGroupName $RGname -ConfigurationPath .\webdsc.ps1 -StorageAccountName knstor5050

# Add DSC Extension with config to the newly created VM

Set-AzureRmVMDscExtension -ResourceGroupName $RGname -VMName $virtualmachine.Name -ArchiveBlobName webdsc.ps1.zip -ArchiveStorageAccountName knstor5050 -ConfigurationName webdsc -Version 2.7 -Location $location

# Good night

Please have a look at these examples, and I encourage you to explore the new opportunities with the AzureRM module.

Happy ARMing!

Monday, May 4, 2015

Azure Site Recovery: Generation 2 VM support

For almost a year ago, Microsoft announced the preview of a cloud service that has turned out to be the leading star when it comes to Hybrid Cloud scenarios, out of the box from Microsoft.

Microsoft Azure Site Recovery let customers extend their datacenter solutions to the cloud to ensure business continuity and availability on-demand.
The solution itself is state of the art and covers many different scenarios – and can rather be seen as their “umbrella” when it comes to availability and recovery in the cloud, as it has several different offerings in different flavors under its wings. 

Besides supporting DR protection of VMware and Physical computers (newly announced), Azure Site Recovery is considered as mandatory for organizations that need DR for their Hyper-V environments, regardless whether the cloud or a secondary location on-prem is the actual DR target.

Just recently, Microsoft announced support for protecting Generation 2 Virtual Machines to Azure.
This is fantastic good news and shows that the journey towards cloud consistency is established for sure.

Let me add some context before we look into the details.

I’ve been working with the brilliant Azure Site Recovery Product Group at Microsoft for a long time now, and I have to admit that these guys are outstanding. Not only do they ship extremely good quality of code, but they also listen to feedback. And when I say listen, they actually engage with you and really tries to understand your concern. In the end of the day, we are all on the same team, working towards the best experience and solution possible.

During TechEd in Barcelona, I was co-presenting “Microsoft Azure Site Recovery: Leveraging Azure as your Disaster Recovery Site” (http://channel9.msdn.com/Events/TechEd/Europe/2014/CDP-B314 ) together with Manoj, and this is when our real discussion started.
Using Azure as the secondary site for DR scenarios makes perfect sense and many customers would like to take benefit from this as soon as possible. However, we often saw that these customers had deployed their virtual machines as Generation 2 VMs – which wasn’t suited for the Azure platform. This was a blocker and the amount of Gen2 VMs were increasing every day.

Earlier in January this year, I made a community survey around the topic and the result was very clear:

Yes – people would love to use Azure as their secondary site, if there was support of Generation 2 VMs in the Cloud.

I am glad to say that the Product Group listened and now we can start to protect workloads on Gen2 VMs too.
But, how does this work?

When you enable a VM for protection, the data is sent to an endpoint in Azure, and nothing special has happened so far.

However, the ASR service will perform a conversion in the service at the time of failover to Gen1.

What?

Let me explain further.

In case of a disaster where you need to perform a failover to Azure, the VM(s) is converted and started as Gen1, running in Azure.
The ASR backend services used during failover has the conversion logic. At failover time, backend service reads Gen2 OS disk and convert the disk to Gen1 OS disk (hence the requirements of the OS disk in Azure).
If you need/want/have to failback to your on-prem Hyper-V environment, the VM will of course be converted back to Gen2.

For more details – check out the official blog post by one of the PM’s, Anoob Backer


Monday, March 2, 2015

DSC with Azure and Azure Pack

Every now and then, it comes a time when I really need to ramp up on certain things.
It can be a new technology, a new product, or a new way of doing things.

This kind of journey is never easy, and I am that kind of person who doesn’t stop before I have a certain level of satisfaction. I expect a lot from myself and have a crazy self-discipline.

Starting early this year, I went deep into DSC to learn more about something that will be impossible to avoid in the next couple of months.

Before continuing, I just want you to know that this will not be yet another blog post that explains the importance of Powershell, which you need to learn ASAP or else you will "flip burgers in the future".

A result of have working with Azure Pack and Azure for the last years has made me much more creative.
Instead of having our out-of-the-box products where we were limited by the actions provided by the GUI, we can now easily create our own custom solutions where integrating several APIs, modules and so on to create new opportunities for our business.

Let us stop for a second on Azure. Microsoft Azure.
We have been talking about the Cloud OS and cloud consistency for over a year now and we should all be very familiar with MS vision and strategy around this topic.
Especially “Mobile first, Cloud first” will give us a hint that whatever comes will appear in Microsoft Azure first.

In the context of DSC, we can see that we can leverage some Azure VM Extensions and Features in our IaaS VMs today.
And that is really the background of this blog post.

Microsoft Azure provides us with several VM Extensions, either directly by Microsoft or some third-parties to enable security, runtime, debugging, management and other features that will boost your productivity working with IaaS VMs in Azure.

When you deploy a virtual machine in the Azure portal, you can decide whether or not the VM Extension should be enabled.

We have several extensions available, all depending on what we are trying to achieve.
The extensions I find most interesting belongs to the category of “Deployment and Configuration Management”.

First, let us talk about a VM extension for “MSEnterpriseApplication”.
Using this Extension, we will effectively implements features that supports VM Roles resource extensions, the same we can leverage on-premises with Azure Pack and Service Provider Foundation.
To add this extension, the VM must already exist in Azure and have the Azure Guest Agent pre-installed.

Running the following cmdlet using the Azure module gives us more details about the extension




With this extension enabled in the VM, we can use the VM Role Authoring tool to author our resource extension (that is the package that we normally import to VMM which contains the application payload). The latest version let us deploy directly to Azure.
If you rather want to use Powershell, you should view the Powershell functionality of the tool and save only the portion of the script that assigns a value to $plainSettings in a text file.

From here, you can store the text file in a variable ($plainSettings) and update your VM with the following cmdlet:

$VM = Set-AzureVMExtension –ExtensionName “MSEnterpriseApplication” –Publisher “Microsoft.SystemCenter” –Version “1.0” –PrivateConfiguration $plainSettings –VM $vmcontext.VM

Next, update your VM directly using the following cmdlet:

Update-AzureVM –ServiceName “ServiceName” –VM $VM –Name “VMName”

So, given the fact that we now have a single tool where we can author and deploy our resource extensions (application payload) to IaaS VMs in both WAP and Azure is good news, however, it is not idempotent.

This is where Desired State Configuration comes into the picture.
Been built on the Common Information Model (CIM) and uses Windows Remote Management (WinRM) as the communication mechanism, DSC is like putting steroids into your Powershell scripts.

I know I will get a lot of Powershell experts on my neck here, but that is at least one way to visualize what DSC is.
Let us say you create a script, deploy it to a node and then you are done.
If someone makes any changes to that configuration afterwards, the Powershell script would not care nor notice.
A Desired State Configuration can ensure that there won’t be any configuration drift and apply and monitor (for example) the configuration.
This is handled by the Local Configuration Manager (LCM) which you can consider as an “agent”, although it is not an agent per definition.

So, looking at the capabilities of DSC, we can quickly understand how important this will be for any in-guest management solution moving forward.

The requirement of using Azure Powershell DSC VM extension is that you must have Azure Powershell module installed. The DSC extension handler has a dependency on Windows Management Framework (WMF) version 5 – which is currently in preview and only supported by 2012 R2. WMF 5.0 will automatically be installed in your IaaS VM as a Windows Update once enabled, and require a reboot.

The following cmdlets are specific to DSC:

Publish-AzureVMDscConfiguration – will upload a DSC script to Azure blob storage, that later will be applied to your IaaS VMs using the Set-AzureVMDscExtension cmdlet

Get-AzureVMDscExtension – Gets the settings of the DSC extension on a particular VM
Remove-AzureVMDscExtension – Will remove the DSC extension from a VM

Set-AzureVMDscExtension – Configures the DSC extension on a VM


Here’s a very easy example on how to apply a DSC script to your VM in Azure, assuming you have the script already created.

Publish-AzureVMDscConfiguration –ConfigurationPath “c:\folder\DSCscript.ps1”

That will create a ZIP package which will be uploaded to a blob storage in Azure.

Next, we will add the config to the VM (which we assume is already stored in the variable named $VM ) )

$VM = Set-AzureVMDscExtension –VM $VM –ConfigurationArchive “DSCscript.ps1.zip” –ConfigurationName “DSCscript”

Once this cmdlet is executed, the following will happen within the VM:

1)      WMF 5.0 is downloaded and installed (the latest version) on the server
2)      The extension handler looks in the specified Azure container (which is defined when you connect with your subscription) for the .zip file
3)      Then the archive is unpacked and any dependent modules are moved into the PS Module path and runs the specified configuration function

Adding that this will also accept parameters gives you an understanding of how flexible, dynamic and powerful the DSC VM Extension will be.

Now, this was all about Microsoft Azure.
What about the things that are taking place in Azure Pack?

I briefly mentioned the VM Role Authoring Tool in this blog post which will be playing an important role in this setting.
The research I have been doing this year isn’t easy to put within a single blog post, especially not if I should describe all the errors and mistakes I have done as part of this journey J

I have been trying to simulate the Azure experience in Windows Azure Pack, but unfortunately, that is an impossible challenge as we don’t have the same possibilities when it comes to the interaction through the API. I am only able to achieve some of the good parts, but that again will qualify for some blog posts in the near future.

Before you start thinking “no, it is not that hard to simulate the exact experience”, I would like to remind you about that everything I do in this context, will always be using Network Virtualization with NVGRE, so there is no data-channel from the datacenter into the tenant environment what so ever.

If you think this is interesting, to learn more about DSC with Azure and Azure Pack, I have to point out the spectacular blog post series by Ben Gelens, where he has done a very good job explaining the complete setup of an entire DSC environment (using Pull) including the authoring of the required VM Role.


I will focus on the Push method in my examples, given the fact that the tenants are isolated and should be able to perform certain actions through self-service.

See you soon!

Monday, January 26, 2015

Reconfigure your Resource Providers for Azure Pack

Configuring your Resource Providers for Azure Pack

While deploying Windows Azure Pack, several factors plays its part when it comes to the design and layout of the solution. As you may be aware of, Windows Azure Pack contains a lot of different sites, APIs and resource providers – just so that you can enable and realize Azure technologies within your own datacenter.
It’s more than a glorified self-service portal so the requirements for the design, load and can be overwhelming for some customers.

Before I get to the big point of this blog post, I would like to put it into some context first.

Normally at customer sites, we see the following different designs when it comes to Windows Azure Pack.

Express



Organizations who want to just test and play around are deploying the single install, express setup of Windows Azure Pack. This will install all the sites and APIs onto a single virtual machine, and the organizations can easily add resource providers to start testing the powerful cloud enabled tool.

Although I have seen some examples where the Express setup has been used in production, it is far from what we recommend. The public facing parts of Azure Pack, such as the Tenant Public API, Tenant Site and eventually Tenant Authentication Site are directly exposed on the internet. Having everything on the same virtual machine will increase the attack surface as well as lead to performance, HA and scale issues.

Configuration requirements using this design:

There aren’t any hard requirements using the Express solution as we like to think that people are only using it in lab and test. However, if you want to make it available and actually use it across firewalls, you will have to perform the following:

·       Reconfigure tenant site (FQDN, certificate and port)
·       Reconfigure tenant authentication site (FQDN, certificate and port)
·       Reconfigure tenant public API (FQDN, certificate and port)

Optional:

·       Reconfigure admin site (FQDN, certificate and port)
·       Reconfigure admin authentication site (FQDN, certificate and port)


Basic



For some of the smaller customers where HA is not the most important thing, we often see a basic implementation of Windows Azure Pack. This means that we have a single virtual machine running the high-privileged services – such as the Admin API, Admin Site, Tenant API and eventually Admin Authentication site together with the default resource providers. This virtual machine is located behind the firewall and in most cases within the same Active Directory Domain with its resource providers (SCVMM+SPF, SQL, ServiceBus, WebSites etc).

For the public facing part (the parts mentioned before, directly exposed on the internet) they use another – dedicated virtual machine which might be located in DMZ and available on the internet.
Of course, both the high-privileged VM and the internet facing VM are running on a Hyper-V cluster so that the VMs themselves are highly available.

Configuration requirements using this design:

I strongly recommend using a highly available WAP design whenever you plan to put it into production. But in this design, the only presence of HA is at the hypervisor level.
You will have to perform the following using this design:

·       Reconfigure tenant site (FQDN, certificate and port)
·       Reconfigure tenant public API (FQDN, certificate and port)
·       Reconfigure tenant authentication site (FQDN, certificate and port)
o   Or
·       Integrate with Active Directory Federation Services and remove tenant authentication site

Optional:

·       Reconfigure admin site (FQDN, certificate and port)
·       Reconfigure admin authentication site (FQDN, certificate and port)
o   Or
·       Integrate with Active Directory Federation Services and remove admin authentication site


Minimal Distribution



The most common design of Windows Azure Pack and what’s normally at least what I am recommending, Is where we have at least two virtual machines for the high-privileged servers, configured as highly available behind a load balancer, and the same for the internet facing part.
This will indeed require load balancers and VIPs, but also some additional reconfiguration when it comes to the Azure Pack environment.

Configuration requirements using this desing

Having the high-privileged services as well as the internet facing parts scaled across several virtual machines, helps us to address performance, availability and scale issues.
You will have to perform the following reconfiguration to make this work:

·       Reconfigure tenat site (FQDN, certificate and port)
·       Reconfigure tenant public API (FQDN, certificate and port)
·       Reconfigure tenant authentication site (FQDN, certificate and port)
o   Or
·       Integrate with Active Directory Federation Services and remove tenant authentication site
·       Reconfigure admin site (FQDN, certificate and port)
·       Reconfigure admin authentication site (FQDN, certificate and port)
o   Or
·       Integrate with Active Directory Federation Services and remove admin authentication site
·       Reconfigure resource providers (FQDN and certificate):
o   Sqlserver
o   MySQL
o   Monitoring
o   Marketplace
o   Usageservice
o   Systemcenter
o   Webspaces
o   Servicebus


Summary

So whenever you plan to scale out and ensure HA across all sites and APIs, you have to reconfigure the components as mentioned with the Minimal Distribution design. The same rules apply if you intend to be more drastic around this, having dedicated VMs for each and every site and API. The reconfiguration is still mandatory.

Windows Azure Pack has been available for over a year now, and the majority of organizations are adopting the VM Cloud resource provider. The good thing here is that even if you have scaled out the SPF endpoint, you are simply adding the endpoint to the admin API and everything is handled.
There’s really not much reconfiguration required if you have configured SPF correctly with FQDN and certificates upfront.

What’s more of a concern is when you want to add resource providers such as SQL server(s) and/or MySQL server(s).

By default, when you install the first high-privileged server with the admin API, admin site and so on, you also get the default resource providers added, such as SQL, MySQL, Usage, Monitoring, Servicebus and Marketplace. The FQDN’s are bound to the computer name of this machine.
Once you add the second – or even third VM that should be located behind a load balancer together with the first VM, these resource providers must also be reconfigured so that you are not pointing toward an individual virtual machine, but towards a FQDN that is associated with a VIP behind the load balancer.

Reconfiguring the default Resource Providers – and why that can be a pain

In order to reconfigure the Windows Azure Pack portals, APIs and resource providers, we have to instrument the databases in a supported way. The supported way is through Powershell, and together with my good friend Flemming Riis, we have convered how to reconfigure the high-privileged services – as well as the internet facing parts in some earlier blog posts.

As a result of that, I won’t cover it over again, but rather refer to those URL’s, hoping you will notice them, read them and continue reading this blog post as I am about to reach my point.





Allright, let us continue on the resource providers.

You are probably familiar with the reconfiguration of the tenant and admin stuff by now, and understand that we have several sets of APIs and portals involved. In the end of the day, everything here should interact nicely together, being able to reach each other and expose the right set of information to both an administrator and a tenant.

If we look at the resource providers we are dealing with directly in the database, we can see that we have several endpoints to each and every resource provider.
We have an endpoint for the resource provider when it comes from the admin API, and we have an endpoint for the resource provider when coming from the tenant site and API.
In addition, each resource provider have an endpoint for usage and notification too.



Example:

The SQLserver resource provider will have the following endpoints:

AdminEndPoint.ForwardingAddress: https://FQDN:30010/
TenantEndPoint.ForwardingAddress: https://FQDN:30010/Subscriptions/
UsageEndPoint.ForwardingAddress: https://FQDN:30010/
NotificationEndPoint.ForwardingAddress: https://FQDN:30010/

So, when only reconfiguring the FQDN, certificates and ports for the high-privileged services and internet facing parts, these endpoints are left behind.

The same is applicable for the other resource providers as well, an in order to turn the in to highly available resource providers, you must perform this through powershell:

Example:

Since ADSF is added to the mix, we need to create a function that will allow us to get the token we require for accessing the AdminURI.

function Get-AdfsToken([string]$adfsAddress, [PSCredential]$credential)
{
    $clientRealm = 'http://azureservices/AdminSite'
    $allowSelfSignCertificates = $true

    Add-Type -AssemblyName 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
    Add-Type -AssemblyName 'System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'

    $identityProviderEndpoint = New-Object -TypeName System.ServiceModel.EndpointAddress -ArgumentList ($adfsAddress + '/adfs/services/trust/13/usernamemixed')
    $identityProviderBinding = New-Object -TypeName System.ServiceModel.WS2007HttpBinding -ArgumentList ([System.ServiceModel.SecurityMode]::TransportWithMessageCredential)
    $identityProviderBinding.Security.Message.EstablishSecurityContext = $false
    $identityProviderBinding.Security.Message.ClientCredentialType = 'UserName'
    $identityProviderBinding.Security.Transport.ClientCredentialType = 'None'

    $trustChannelFactory = New-Object -TypeName System.ServiceModel.Security.WSTrustChannelFactory -ArgumentList $identityProviderBinding, $identityProviderEndpoint
    $trustChannelFactory.TrustVersion = [System.ServiceModel.Security.TrustVersion]::WSTrust13

    if ($allowSelfSignCertificates)
    {
        $certificateAuthentication = New-Object -TypeName System.ServiceModel.Security.X509ServiceCertificateAuthentication
        $certificateAuthentication.CertificateValidationMode = 'None'
        $trustChannelFactory.Credentials.ServiceCertificate.SslCertificateAuthentication = $certificateAuthentication
    }

    $ptr = [System.Runtime.InteropServices.Marshal]::SecureStringToCoTaskMemUnicode($credential.Password)
    $password = [System.Runtime.InteropServices.Marshal]::PtrToStringUni($ptr)
    [System.Runtime.InteropServices.Marshal]::ZeroFreeCoTaskMemUnicode($ptr)

    $trustChannelFactory.Credentials.SupportInteractive = $false
    $trustChannelFactory.Credentials.UserName.UserName = $credential.UserName
    $trustChannelFactory.Credentials.UserName.Password = $password #$credential.Password

    $rst = New-Object -TypeName System.IdentityModel.Protocols.WSTrust.RequestSecurityToken -ArgumentList ([System.IdentityModel.Protocols.WSTrust.RequestTypes]::Issue)
    $rst.AppliesTo = New-Object -TypeName System.IdentityModel.Protocols.WSTrust.EndpointReference -ArgumentList $clientRealm
    $rst.TokenType = 'urn:ietf:params:oauth:token-type:jwt'
    $rst.KeyType = [System.IdentityModel.Protocols.WSTrust.KeyTypes]::Bearer

    $rstr = New-Object -TypeName System.IdentityModel.Protocols.WSTrust.RequestSecurityTokenResponse

    $channel = $trustChannelFactory.CreateChannel()
    $token = $channel.Issue($rst, [ref] $rstr)

    $tokenString = ([System.IdentityModel.Tokens.GenericXmlSecurityToken]$token).TokenXml.InnerText;
    $result = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($tokenString))
    return $result
} 

Next, we will list the resource providers we have and query for the endpoints:


### Change the variables to fit your environment

$adfsAddress = 'https://adfsserver.com
$username = 'domain\username'
$password = 'P@@$Word'
$adminuri = ‘https://adminapi.domain.com:30004’
$securePassword = ConvertTo-SecureString -String $password -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$securePassword

$token = Get-AdfsToken -adfsAddress $adfsAddress -credential $credential

$token

$FQDN = ‘https://wap.domain.com’

### Get a list of all your resource providers

Get-MgmtSvcResourceProvider -IncludeSystemResourceProviders -AdminUri $adminUri -Token $token -DisableCertificateValidation | Format-List -Property "Name"

Get-MgmtSvcResourceProvider -IncludeSystemResourceProviders -AdminUri $adminuri -Token $token -DisableCertificateValidation | fl -Property "name"

# Get a list of resource providers with the current configured endpoint values
$rp = Get-MgmtSvcResourceProvider -IncludeSystemResourceProviders -AdminUri $adminUri -Token $token -DisableCertificateValidation
$rp | Select Name, @{e={$_.AdminEndPoint.ForwardingAddress}}, @{e={$_.TenantEndpoint.ForwardingAddress}}, @{e={$_.UsageEndpoint.ForwardingAddress}}, @{e={$_.healthcheckendpoint.forwardingaddress}}, @{e={$_.notificationendpoint.forwardingaddress}}

# STEP 1 - Configure new FQDN for the SQLserver resource provider

$resourceProviderName = "sqlservers"
$adminEndpoint = "https://$FQDN:30010/"
$tenantEndpoint = "https://$FQDN:30010/subscriptions"
$usageEndpoint = "https://$FQDN:30010/"
$healthCheckEndpoint = $null
$notificationEndpoint = "https://$FQDN:30010/"


$rp = Get-MgmtSvcResourceProvider -Name $resourceProviderName -IncludeSystemResourceProviders -AdminUri $adminUri -Token $token -DisableCertificateValidation
# update all the endpoints using the new fqdn:
if ($rp.AdminEndpoint -and $adminEndpoint) {
# update endpoint
$rp.AdminEndpoint.ForwardingAddress = New-Object System.Uri($adminEndpoint)
}
if ($rp.TenantEndpoint -and $tenantEndpoint) {
# update endpoint
$rp.TenantEndpoint.ForwardingAddress = New-Object System.Uri($tenantEndpoint)
}
if ($rp.UsageEndpoint -and $usageEndpoint) {
# update endpoint
$rp.UsageEndpoint.ForwardingAddress = New-Object System.Uri($usageEndpoint)
}
if ($rp.HealthCheckEndpoint -and $healthCheckEndpoint) {
# update endpoint
$rp.HealthCheckEndpoint.ForwardingAddress = New-Object System.Uri($healthCheckEndpoint)
}
if ($rp.NotificationEndpoint -and $notificationEndpoint) {
# update endpoint
$rp.NotificationEndpoint.ForwardingAddress = New-Object System.Uri($notificationEndpoint)
}

Set-MgmtSvcResourceProvider -ResourceProvider $rp -AdminUri $adminUri -Token $token -DisableCertificateValidation -Force

# Repeat STEP 1 and STEP 2 on the remaining resource providers



 By following the steps in this blog post, you shouldn’t have any warnings or errors in your WAP portals.