This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Output "Hello from Runbook" | |
$apimSubscriptionId = "YOUR_SUBSCRIPTION_ID" | |
$apimServiceName = "YOUR_APIM_SERVICE_NAME" | |
$rg = "YOUR_RESOURCE_GROUP" | |
# Copy/paste from default runbook | |
function setupConnection { | |
Write-Output "Start process getting AzureRunAsConnection" | |
$connectionName = "AzureRunAsConnection" | |
try | |
{ | |
# Get the connection "AzureRunAsConnection " | |
$servicePrincipalConnection = Get-AutomationConnection -Name $connectionName | |
Write-Output $servicePrincipalConnection | |
"Logging in to Azure..." | |
Add-AzAccount ` | |
-ServicePrincipal ` | |
-TenantId $servicePrincipalConnection.TenantId ` | |
-ApplicationId $servicePrincipalConnection.ApplicationId ` | |
-CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint | |
} | |
catch { | |
if (!$servicePrincipalConnection) | |
{ | |
$ErrorMessage = "Connection $connectionName not found." | |
throw $ErrorMessage | |
} else{ | |
Write-Error -Message $_.Exception | |
throw $_.Exception | |
} | |
} | |
} | |
# Connecting to your Azure account | |
setupConnection | |
# Setting the context for apim | |
Set-AzContext -Subscription $apimSubscriptionId | |
$context = New-AzApiManagementContext -ResourceGroupName $rg -ServiceName $apimServiceName | |
# Random value | |
$value = [System.TimeZoneInfo]::ConvertTimeToUtc((get-date), (Get-TimeZone)) | |
Set-AzApiManagementNamedValue -Context $context -NamedValueId "test" -Value $value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment