我们在 Azure 虚拟机中运行节点应用程序,同时我们也想在某个时间借助 Azure 自动化(或通过管理门户)重新启动 VM。
但是VM重启后如何重启node应用呢?
我们尝试了很多方法来实现这一点,包括添加任务计划程序、将命令添加到注册表项 ( LocalMachine\..\Run)、使用 VM 的自定义脚本扩展......
以上都失败了。我们想要的是在虚拟机重启后,节点应用程序可以自动启动。如果我们然后使用预定义的帐户远程访问 VM,则上述一些方法可以工作。然而,这不是风景,我们只想在一开始就远程一次,而不是每次重启。
那么,实现此目的的正确方法是在VM自动重启后启动进程或执行命令而无需手动登录?
powershell startupscript azure azure-virtual-machine azure-automation
在此链接中(使用来自java的REST api创建azure自动化帐户)我询问了如何创建自动化帐户以创建Runbook.现在,我已经创建了一个自动化帐户以及一个已发布的Runbook,我想执行(启动)Runbook.为了做到这一点,我正在关注此链接(https://msdn.microsoft.com/en-us/library/azure/mt163849.aspx),但我收到一个错误:
Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
 <h2>404 - File or directory not found.</h2>
 <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable
Run Code Online (Sandbox Code Playgroud)
这是java函数:
private static int processPutRequest(URL url, byte[] data, String contentType, String keyStore, String keyStorePassword)
throws UnrecoverableKeyException, KeyManagementException, KeyStoreException, NoSuchAlgorithmException, IOException {
SSLSocketFactory sslFactory = getSSLSocketFactory(keyStore, keyStorePassword);
HttpsURLConnection con = null;
con = (HttpsURLConnection) url.openConnection();
con.setSSLSocketFactory(sslFactory);
con.setDoOutput(true);
con.setRequestMethod("PUT");
con.addRequestProperty("x-ms-version", "2013-08-01");
con.setRequestProperty("Content-Length", String.valueOf(data.length));
con.setRequestProperty("Content-Type", contentType);
DataOutputStream …Run Code Online (Sandbox Code Playgroud) 作为模板的一部分,我想要检索OMS/Operational Insights工作区的SharedKeys,而不是必须将其作为参数传递.
这可能吗?我在这里关注文档
Microsoft.OperationalInsights/workspaces/资源提供程序似乎没有任何list*提供程序操作,我找不到任何其他的引用:
Get-AzureRmProviderOperation -OperationSearchString * | where {$_.Operation -like "*operational*sharedkeys*"} | FT Operation
Microsoft.OperationalInsights/workspaces/sharedKeys/action
Run Code Online (Sandbox Code Playgroud)
我想要的用法:
"variables": { workspaceKey: "[listKeys(parameters('workspaceResourceId'), '2015-05-01-preview').primarySharedKey]" }
Run Code Online (Sandbox Code Playgroud)
在此期间,假设实际上不支持此功能,我在Log Analytics UserVoice站点上添加了对它的请求
json azure azure-resource-manager azure-automation azure-rm-template
在旧版本的Microsoft.IdentityModel.Clients.ActiveDirectory中,存在带有PromptBehavior参数的AcquireToken
var context = new AuthenticationContext("https://login.windows.net/tenantId");
var result = context.AcquireToken(clientId: clientIdValue, redirectUri: new Uri("http://localhost/Appcycle"), resource: "https://management.core.windows.net/", promptBehavior: PromptBehavior.Auto);
Run Code Online (Sandbox Code Playgroud)
在Microsoft.IdentityModel.Clients.ActiveDirectory v3.10中只有AcquireTokenAsync
var authParam = new PlatformParameters(PromptBehavior.Auto,false);
var result = context.AcquireTokenAsync("https://management.core.windows.net/", clientid, new Uri("http://localhost/AppPoolRecycle"), authParam);
result.Wait();
Run Code Online (Sandbox Code Playgroud)
当我运行这个时,我得到错误 {"无效的所有者窗口类型.预期的类型是IWin32Window或IntPtr(用于窗口句柄)."}
不确定这是否是由于我在控制台应用程序上运行.如果是这样,我如何让它工作?
我正致力于在Azure VM上自动部署我们的产品.我正在使用Powershell DSC和Azure自动化来配置VM.
其中一个要求是为VM上的用户导入pfx证书到CurrentUser/My.我试图使用以下脚本资源执行此操作:
Script InstallSelfSignedCertificatesToMy
{
GetScript = {
}
SetScript = {
$Path = "c:\test"
$Pass = ConvertTo-SecureString "password"-AsPlainText -Force
Import-PfxCertificate -FilePath "$($Path)\example.pfx" cert:\currentUser\my -Password $Pass
}
TestScript = {
return $false
}
Credential = $adminCredential
}
Run Code Online (Sandbox Code Playgroud)
$ adminCredential参数具有我要导入证书的用户的凭据.
此DSC不报告任何故障,但证书未添加到用户的CurrentUser/My上.
一个有趣的观察是,如果我使用Start-DscConfiguration在VM上本地运行DSC,它将按预期工作并安装证书.如果从Azure自动化调用它,它不起作用.
任何人都可以指出这里可能存在的问题吗?有没有人试图做类似的事情?
提前致谢.
当我尝试将变量部署到 Azure 自动化资产时,出现错误并且无法部署我的资源。
假设这个模板
{
"name": "myVariable",
"type": "Microsoft.Automation/automationAccounts/variables",
"apiVersion": "2015-10-31",
"dependsOn": [
"[resourceId('Microsoft.Automation/automationAccounts', variables('automationAccountName'))]"
],
"location": "[variables('automationLocation')]",
"properties": {
"isEncrypted": "false",
"value": "8f703df8-0448-4ee3-8629-fc3f01840683"
}
}
Run Code Online (Sandbox Code Playgroud)
部署向我抛出异常:
{\"Message\":\"The request is invalid.\",\"ModelState\":{\"variable.properties.value\":[\"Invalid JSON primitive: a7d14fb0-232e-4fa0-a748-c7c8fb2082e2.\"]}}
我也尝试过:
"value": "\"8f703df8-0448-4ee3-8629-fc3f01840683\""
Run Code Online (Sandbox Code Playgroud)
但是任何尝试都失败了!
任何人都知道如何使用 ARM 模板配置可变资产?
azure azure-resource-manager azure-automation azure-rm-template
我创建了一个示例 Azure 自动化 Powershell Runbook。我正在尝试执行 SQL 命令,然后将该命令中的消息打印到 Workbook 输出中。
我的代码取自使用 PowerShell 从 SQL Server 捕获 InfoMessage 输出,如果我在本地运行它,它就可以工作:
Write-Output "Starting"
$conn = New-Object System.Data.SqlClient.SqlConnection "Data Source=abc.database.windows.net,1433;Initial Catalog=def;Integrated Security=False;User ID=ghj;Password=qwe"
## Attach the InfoMessage Event Handler to the connection to write out the messages
$handler = [System.Data.SqlClient.SqlInfoMessageEventHandler] {param($sender, $event) Write-Output $event.Message };
$conn.add_InfoMessage($handler);
$conn.FireInfoMessageEventOnUserErrors = $true;
$conn.Open();
$cmd = $conn.CreateCommand();
$cmd.CommandText = "PRINT 'This is the message from the PRINT statement'";
$cmd.ExecuteNonQuery();
$cmd.CommandText = "RAISERROR('This is the message from the …Run Code Online (Sandbox Code Playgroud) 我在创建 Azure 自动化帐户时收到以下错误。
{ "status": "Failed", "error": { "code": "DeploymentFailed", "message": "至少一项资源部署操作失败。请列出部署操作以了解详细信息。请参阅https://aka。 ms/DeployOperations了解使用详细信息。", "details": [ { "code": "BadRequest", "message": "{\r\n "error": {\r\n "code": "InvalidPrivateDnsZoneIds", \r\n "message": "私有 DNS 区域组 /subscriptions/012a3201-bf61-4cd6-b0cb-05213d7410b4/resourceGroups/AzureAutomation/providers/Microsoft.Network/privateEndpoints/AVD-Auto/privateDnsZoneGroups/default 具有无效的私有 DNS 区域ids .",\r\n "详细信息": []\r\n }\r\n}" } ] } }
我想使用Get-AzureRm*Automation Runbook中的命令获取所有属性,但是以下内容返回异常。如何编写代码以正确运行这些命令?
Write-Output $PSVersionTable
$resourceGroupName = "(snipped)"
$appServicePlans = Get-AzureRmAppServicePlan -ResourceGroupName $resourceGroupName
$Cred = Get-AutomationPSCredential -Name "pscred" # works as expected
Add-AzureRmAccount -Credential $Cred
Add-AzureAccount -Credential $Cred
$appServicePlans = `
Get-AzureRmAppServicePlan -ResourceGroupName $resourceGroupName
$appServices = `
Get-AzureRmWebApp -ResourceGroupName $resourceGroupName
$storageAccounts = `
Get-AzureRmStorageAccount -ResourceGroupName $resourceGroupName
Run Code Online (Sandbox Code Playgroud)
通过管理门户中的[测试]
Name Value
---- -----
PSVersion 5.0.10514.2
WSManStackVersion 3.0
SerializationVersion 1.1.0.1
CLRVersion 4.0.30319.19455
BuildVersion 10.0.10514.2
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
Get-AzureRmAppServicePlan : The …Run Code Online (Sandbox Code Playgroud) 是否可以使用c#或Azure自动化自动调整CosmosDB吞吐量?请提供示例示例.
azure-automation ×10
azure ×7
powershell ×4
api ×1
c# ×1
dsc ×1
java ×1
json ×1
pfx ×1
rest ×1
sql-server ×1