天道酬勤,学无止境

azure-automation

Authenticating to Azure Resource Manager with a Service Principal in Azure Automation

So there's now a documented workaround to use ARM in Azure Automation, and it's also well documented how to authenticate to ARM using a Service Principal. But even after following these steps I still cannot get the combination of those to work. Running my runbook in Automation with a Service Principal always gives the following error: New-AzureTag : Your Azure credentials have not been set up or have expired, please run Add-AzureAccount to set up your Azure credentials. At Add-SubscriptionTags:48 char:48 + + CategoryInfo : CloseError: (:) [New-AzureTag], ArgumentException +

2021-11-27 04:03:41    分类:问答    azure   azure-automation   azure-resource-manager

Azure AD authentication without app registration

I want to access Azure Directories and Subscriptions using my web app hosted on my server but i do not want to register my app in active directory because i do not have permissions to register my app in active directory I want to authenticate users from out of my active directory too. for example following sites let you authenticate any Azure AD user. https://resources.azure.com/ https://azureiotsuite.com Please help me to where to start. i have tried Azure AD authentication but it asks you to register your app in Azure AD Apps.

2021-11-23 06:07:11    分类:问答    azure   azure-active-directory   azure-resource-manager   azure-automation   azure-authentication

用于复制所有 webapp 设置的 Azure Runbook powershell 脚本(Azure runbook powershell script to copy all webapp settings)

问题 我正在尝试将以下脚本作为 Runbook 运行,以将所有设置从一个 Web 应用程序复制到另一个 Web 应用程序,但出现以下错误。 try { $acct = Get-AzureRmSubscription } catch { Login-AzureRmAccount } $fromResourceGroup = 'resourceG1' $fromSite = 'website1' $toResourceGroup = 'resourceG2' $toSite = 'website2' $props = (Invoke-AzureRmResourceAction -ResourceGroupName $fromResourceGroup -ResourceType Microsoft.Web/sites/Config -Name $fromSite/appsettings -Action list -ApiVersion 2015-08-01 -Force).Properties $hash = @{} $props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $props.($_.Name) } Set-AzureRMWebApp -ResourceGroupName

2021-11-21 04:39:31    分类:技术分享    powershell   azure   azure-automation

如何从 PSWorkflow Runbook 内的 InlineScript 将 PowerShell 脚本作为 Azure 自动化 Runbook 执行?(How to execute PowerShell script as Azure Automation Runbook from InlineScript inside PSWorkflow runbook?)

问题 在 PowerShell 工作流活动中,我可以使用 InlineScript 调用本机 PowerShell 脚本: workflow test { InlineScript { .\script.ps1 } } 但是在 Azure 自动化中,点路径(至少在我的测试中)返回c:\windows\system32 ,并且 Azure 自动化中的脚本即运行手册不存在(或者更确切地说,它无法执行,因为它可以找不到脚本)。 是否可以像这样执行存储在 AAuto 中的本机 PS Runbook? 如果是这样,我如何指定文件的路径? 这是 Azure 自动化的工作流 Runbook 和 InlineScript 活动的解析/编译过程中的错误/疏忽,阻止了从属 Runbook 被复制到工作人员? 我做了一点搜索,发现在执行原生 PS runbook 时: 首先检查它们是否有任何其他 Runbook 引用。 作为部署到 worker 执行的一部分,在C:\Temp\下创建一个随机命名的文件夹引用的 Runbook 最终会复制到此文件夹中。 如果未找到引用的 Runbook,则不会将它们复制到临时目录。 根 Runbook 似乎没有复制到文件夹中。 执行工作流 Runbook 时,不会创建动态命名的文件夹(在 c:\Temp 下)。 作为标准工作流编译的一部分,InlineScript

2021-11-21 04:15:14    分类:技术分享    powershell   azure   azure-automation   powershell-workflow

How to execute PowerShell script as Azure Automation Runbook from InlineScript inside PSWorkflow runbook?

In a PowerShell Workflow activity, I can call a native PowerShell script using InlineScript: workflow test { InlineScript { .\script.ps1 } } But in Azure Automation, the dot-path (at least in my tests) was returning c:\windows\system32, and the script-as-runbook in Azure Automation did not exist there (or rather, it failed to execute because it could not find the script). Is it possible to execute a native PS runbook stored in AAuto like this? If so, how do I specify the path to the file? Is this a bug/oversight in Azure Automation's parsing/compilation process of Workflow runbooks &

2021-11-12 12:20:24    分类:问答    powershell   azure   azure-automation   powershell-workflow

Azure 自动化 PowerShell 脚本运行命令两次(Azure Automation PowerShell Script runs commands twice)

问题 我有一个 Azure 自动化 PowerShell 脚本,计划每晚运行。 出于某种原因,工作流会时不时地运行,然后在正在运行的工作流的同一实例中再次从头开始运行所有命令。 我没有循环整个工作流程或任何东西,所以我不知道这是如何或为什么发生的。 有什么想法吗? 这是代码: workflow Start-SQLDatabaseBackup { param( [parameter(Mandatory=$true)] [string] $credName = 'automation', [parameter(Mandatory=$true)] [string] $SubscriptionName, [parameter(Mandatory=$true)] [string] $SQLServerName, [parameter(Mandatory=$true)] [string] $DatabaseName, [parameter(Mandatory=$true)] [string] $StorageAccountName, [parameter(Mandatory=$true)] [string] $ContainerName ='backup', [parameter(Mandatory=$false)] [string] $time ) inlinescript { Write

2021-11-12 09:23:51    分类:技术分享    powershell   azure   azure-powershell   azure-automation

Azure runbook powershell script to copy all webapp settings

I am trying to run the following script as a runbook to copy all settings from one webapp to another but I get the following error. try { $acct = Get-AzureRmSubscription } catch { Login-AzureRmAccount } $fromResourceGroup = 'resourceG1' $fromSite = 'website1' $toResourceGroup = 'resourceG2' $toSite = 'website2' $props = (Invoke-AzureRmResourceAction -ResourceGroupName $fromResourceGroup -ResourceType Microsoft.Web/sites/Config -Name $fromSite/appsettings -Action list -ApiVersion 2015-08-01 -Force).Properties $hash = @{} $props | Get-Member -MemberType NoteProperty | % { $hash[$_.Name] = $props

2021-11-11 11:48:37    分类:问答    powershell   azure   azure-automation

Azure 自动化:身份验证成功但未返回订阅,但可在本地 powershell 中运行(Azure automation: Authentication succeeds but no subscriptions are returned, works in local powershell though)

问题 在创建可按需复制数据库的 azure 自动化运行手册时遇到问题; 我创建了一个凭据并存储了我用来登录门户的帐户的 u/p。 密码写在记事本中并粘贴进去以确保正确。 $Cred = Get-AutomationPSCredential -Name 'automationCredential' Write-Output "UN: $($Cred.Username)" Write-Output "PW: $($Cred.Password.Length)" Add-AzureRmAccount -Credential $Cred Write-Output "Deleting the old $TargetDatabaseName" Remove-AzureRMSqlDatabase -ResourceGroupName "Default-SQL-NorthEurope" -ServerName $SourceServerName -DatabaseName $TargetDatabaseName -Force Write-Output "Creating new $TargetDatabaseName with data at time $PointInTime" New-AzureRmSqlDatabaseCopy ` -CopyDatabaseName

2021-11-10 19:22:47    分类:技术分享    azure-powershell   azure-automation   azure-authentication

Azure Automation PowerShell Script runs commands twice

I have a Azure Automation PowerShell script the gets scheduled to run every night. For some reason every once and while the workflow will run and then just start running all the commands from the beginning again in the same instance of the running workflow. I am not looping the whole workflow or anything so i do not know how or why this is happening. Any thoughts? Here is the code: workflow Start-SQLDatabaseBackup { param( [parameter(Mandatory=$true)] [string] $credName = 'automation', [parameter(Mandatory=$true)] [string] $SubscriptionName, [parameter(Mandatory=$true)] [string] $SQLServerName

2021-11-09 08:58:24    分类:问答    powershell   azure   azure-powershell   azure-automation

Azure 自动化:调用 URL(Azure Automation: Calling a URL)

问题 我是 Azure 自动化的新手。 我想每个工作日早上调用一个 URL 并获取它的 HTML 一次。 这是我到目前为止所写的。 workflow Wakeup-Url { Param ( [parameter(Mandatory=$true)] [String] $Url ) $day = (Get-Date).DayOfWeek if ($day -eq 'Saturday' -or $day -eq 'Sunday'){ exit } $output = "" InlineScript {"$Using:output = (New-Object System.Net.WebClient).DownloadString(`"$Using:Url`");"} write-output $output } 当我测试 Runbook 时,它没有在输出中给我 HTML。 相反,我在输出窗格中得到的是: = (New-Object System.Net.WebClient).DownloadString("https://my.url.com/abc.html"); 回答1 您的 InlineScript 当前只是输出一个包含您的脚本的字符串,因为您在整个表达式周围加上了引号: InlineScript {"$Using:output = (New-Object System.Net

2021-11-09 08:47:41    分类:技术分享    azure   azure-automation