Deploying Connector on the Endpoint Itself Overview
Prepare the script
1. Download the PowerShell script (Azure-DeployJetPatchConnectorOnWindows.ps1)
2. Edit and Configure your CoreServerURL in PowerShell script just downloaded.
-coreserverurl="https://Your_JetPatch_Server_IP_or_Hostname/vmanage-server/"
Install Connector Using Azure portal (One VM Installation)
1. Navigate to your Classic VM resource. Select Extensions under Settings.
2. Click + Add and in the list of resources choose Custom Script Extension.
3. Click Create
4. On the Install extension page, click on Browse then navigate to the Storage account you want to use or create one.
5. Select/Create the Container you want to use.
6. Upload the PowerShell file and Select it.
7. Click OK
Once the OK button is clicked, the deployment will start. You should see the status as a notification
On the extension page, you can have a look at the status and check that the deployment is successfully done. (Provisioning Succeeded)
8. Now connect to your JetPatch server and check that you can see the machine on the "Servers" page.
Install Connector Using Azure Shell (Multiple VMs Installations)
How does it work?
Once you have prepared the script you should copy it as a blob to the storage account. Once it is done you should provide proper input parameters to script, limit the scope of virtual machines to which it should apply (line 12 of a script) and this is the way to add custom script extension to multiple machines on Azure.
IMPORTANT:
You should keep in mind that the script will remove the custom script extension if it already exists on the machine. It will not destroy changes applied by this script, but only the extension itself. The reason of that is the Azure VMs do not support more than one same type of extension installed.
Requirements:
- Az module installed
- Proper access to the subscription where you have a storage account and virtual machines – best Contributor
Script to customize:
param(
$TenantId = ???
$defaultSubscriptionId = ???
$customScriptExtensionName = JetPatch_Connector
$scriptName = Azure-DeployJetPatchConnectorOnWindows.ps1
$storageAccountName = ???
$storageAccountContainer = ???
$storageAccountResourceGroup = ???
$storageSubscriptionId = ???
)
$VMs = Get-AzVM ## Here you should apply filter if you want to limit installation to specific VMs (See article for parameters https://shorturl.at/nCPUV )
Select-AzSubscription -SubscriptionId $storageSubscriptionId
$fileUri = @("https://$storageAccountName.blob.core.windows.net/$storageAccountContainer/$scriptName")
$settings = @{"fileUris" = $fileUri};
$storageKey = (Get-AzStorageAccountKey -Name $storageAccountName -ResourceGroupName $storageAccountResourceGroup)[0].Value
$protectedSettings = @{"storageAccountName" = $storageAccounttName; "storageAccountKey" = $storageKey; "commandToExecute" = "powershell -ExecutionPolicy Unrestricted -File $scriptName"};
Select-AzSubscription -SubscriptionId $defaultSubscriptionId
foreach($vm in $VMs){
Write-Output "Starting VM $($vm.Name)"
Start-AzVm -ResourceGroupName "$($vm.ResourceGroupName)" -Name "$($vm.Name)"
Write-OUtput "Working on vm $($vm.Name)"
$extensions = (Get-AzVm -ResourceGroupName "$($vm.ResourceGroupName)" -Name "$($vm.Name)").Extensions
foreach($ext in $extensions)
{
if($ext.VirtualMachineExtensionType -eq "CustomScriptExtension"){
Write-Output "Removing CustomScriptExtension with name $($ext.Name) from vm $($vm.Name)"
Remove-AzVMExtension -ResourceGroupName "$($vm.ResourceGroupName)" -VMName "$($vm.Name)" -Name $ext.Name -Force
Write-Output "Removed CustomScriptExtension with name $($ext.Name) from vm $($vm.Name)"
}
}
Write-Output "$customScriptExtenstionName installation on VM $($vm.Name)"
Set-AzVMExtension -ResourceGroupName "$($vm.ResourceGroupName)" `
-Location "$($vm.Location)" `
-VMName "$($vm.Name)" `
-Name "$customScriptExtenstionName" `
-Publisher "Microsoft.Compute" `
-ExtensionType "CustomScriptExtension" `
-TypeHandlerVersion "1.10" ` `
-Settings $settings `
-ProtectedSettings $protectedSettings
Write-Output "---------------------------"
}
Comments
0 comments
Article is closed for comments.