Skip to content

Commit b69765a

Browse files
Merge pull request #168 from shriramnat/master
Added Location modification
2 parents 7f60396 + 7d0be9a commit b69765a

3 files changed

Lines changed: 52 additions & 3 deletions

File tree

Infrastructure/AzureStack.Infra.psm1

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,39 @@ $IPPoolBodyJson =$IPPoolBody |ConvertTo-Json
799799
}
800800
export-modulemember -function Add-AzSIPPool
801801

802+
Function Set-AzSLocationInformation {
803+
Param(
804+
[Parameter(Mandatory = $true)]
805+
[ValidateNotNullorEmpty()]
806+
[String] $TenantId,
807+
808+
[Parameter(Mandatory = $true)]
809+
[System.Management.Automation.PSCredential] $AzureStackCredentials,
810+
811+
[Parameter(Mandatory = $true)]
812+
[string] $EnvironmentName,
813+
814+
[Parameter(Mandatory = $true)]
815+
[string] $Region = 'local',
816+
817+
[Parameter(Mandatory = $true)]
818+
[string] $Latitude = '47.608013',
819+
820+
[Parameter(Mandatory = $true)]
821+
[string] $Longitude = '-122.335167'
822+
)
823+
$ArmEndpoint = GetARMEndpoint -EnvironmentName $EnvironmentName -ErrorAction Stop
824+
$subscription, $headers = (Get-AzureStackAdminSubTokenHeader -TenantId $TenantId -AzureStackCredentials $AzureStackCredentials -EnvironmentName $EnvironmentName)
825+
$uri = "{0}/subscriptions/{1}/providers/Microsoft.Subscriptions.Admin/locations/{2}?api-version=2015-11-01" -f $ArmEndpoint, $subscription, $Region
826+
827+
$obtainedRegion = Invoke-RestMethod -Method GET -Uri $uri -ContentType 'application/json' -Headers $headers
828+
$obtainedRegion.latitude = $Latitude
829+
$obtainedRegion.longitude = $Longitude
830+
831+
Invoke-WebRequest -Uri $uri -Method PUT -Body $(Convertto-Json $obtainedRegion) -ContentType 'application/json' -Headers $headers
832+
}
833+
Export-ModuleMember -function Set-AzSLocationInformation
834+
802835
Function GetARMEndpoint{
803836
param(
804837
# Azure Stack environment name
@@ -816,4 +849,4 @@ Function GetARMEndpoint{
816849
}
817850

818851
$ARMEndpoint
819-
}
852+
}

Infrastructure/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,4 +421,17 @@ Start-AzSInfraRoleInstance -AzureStackCredentials $credential -TenantID $TenantI
421421
422422
#Validate if error is resolved (Can take up to 3min)
423423
Get-AzSAlert -AzureStackCredentials $credential -TenantID $TenantID -EnvironmentName "AzureStackAdmin"|where {$_.state -eq "active"}
424+
```
425+
426+
427+
### Set Azure Stack's Latitude and Longitude
428+
429+
This command modifies an Azure Stack instance's latitude and longitude location
430+
431+
```powershell
432+
$credential = Get-Credential
433+
$latitude = '12.972442'
434+
$longitude = '77.580643'
435+
$regionName = 'local'
436+
Set-AzSLocationInformation -TenantID $AadTenant -EnvironmentName $EnvironmentName -AzureStackCredentials $credential -Region $regionName -Latitude $latitude -Longitude $longitude
424437
```

Infrastructure/Tests/Infra.Tests.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ InModuleScope $script:ModuleName {
3737
$EnvironmentName = $global:EnvironmentName
3838

3939

40-
4140
Describe 'Infra - Functional Tests' {
4241
It 'Get-AzSAlert should not throw' {
4342
{ Get-AzSAlert -TenantID $AadTenant -EnvironmentName $EnvironmentName -AzureStackCredentials $stackLoginCreds } |
@@ -80,9 +79,13 @@ InModuleScope $script:ModuleName {
8079
{ Get-AzSUpdate -TenantID $AadTenant -EnvironmentName $EnvironmentName -AzureStackCredentials $stackLoginCreds } |
8180
Should Not Throw
8281
}
82+
It 'Set-AzSLocationInformation should not throw' {
83+
{ Set-AzSLocationInformation -TenantID $AadTenant -EnvironmentName $EnvironmentName -AzureStackCredentials $stackLoginCreds -Region 'local' -Latitude '12.972442' -Longitude '77.580643'} |
84+
Should Not Throw
85+
}
8386

8487

8588
}
8689

8790

88-
}
91+
}

0 commit comments

Comments
 (0)