Azure自动化Get-Azure不返回任何内容(Azure Automation Get-Azure not returning anything)
在解决了这些问题之后,我想要更新博客:
注意:机密内容替换为:xxx
注意2:我无法使我的代码块周围的格式正常工作,所以道歉。
我一直在使用Azure自动化。
我想每晚关闭使用stop-AzureVM并在早上重启以节省资金。
我可以使用PowerShell ISE从我的本地计算机调用get-AzureVM,但是当我在Azure门户中的Azure自动化中运行我的powershell脚本时,get-AzureVM不会返回任何内容,因此,我无法获取我的VM并因此阻止它。
这是我的跑步书中的脚本:
workflow Stop-MyVM { # Specify Azure Subscription Name $subName = 'My subscription Connection' # Connect to Azure Subscription Connect-Azure -AzureConnectionName $subName Select-AzureSubscription -SubscriptionName $subName $vm = Get-AzureVM -ServiceName 'xxx-xxxx' -Name 'xxx-xxxVM' Write-Output "VM NAME: $vm" # stop code to go here when I work out why get-AzureVM is not working }
我还有2个资产: 连接: 证书:
我还有另一本运行书,我从网上下载以连接到Azure。 这是非常标准的,不会导致问题:
无效但无错误的行是: $ vm = Get-AzureVM -ServiceName'xxx-xxx'-Name'xxx-xxxVM'
这是输出:
UPDATE TO BLOG I WROTE AFTER THIS ISSUES WAS SOLVED:
Click here to see my blog post on this
Note: confidential stuff replaced by: xxx
Note2: I could not get the formatting around my code blocks to work correctly so apologies for this.
I have been working with Azure Automation.
I want to shut down using stop-AzureVM nightly and restart it in the morning to save money.
I can call get-AzureVM from my local machine using powershell ISE but when I run my powershell script in Azure Automation in the Azure portal, get-AzureVM doesn't return anything and hence, I can't get my VM and therefore stop it.
Here is my script in my run book:
workflow Stop-MyVM { # Specify Azure Subscription Name $subName = 'My subscription Connection' # Connect to Azure Subscription Connect-Azure -AzureConnectionName $subName Select-AzureSubscription -SubscriptionName $subName $vm = Get-AzureVM -ServiceName 'xxx-xxxx' -Name 'xxx-xxxVM' Write-Output "VM NAME: $vm" # stop code to go here when I work out why get-AzureVM is not working }
I also have 2 assets: Connection: Certificate:
I also have another run book that I downloaded from the web to connect to Azure. This is pretty standard and is not causing the issue:
The line that is not working but not erroring is: $vm = Get-AzureVM -ServiceName 'xxx-xxx' -Name 'xxx-xxxVM'
Here is the output:
原文:
最满意答案
在你的changeSquare方法中,尝试这样的事情:
var frame2 = $('#frame2', top.document) //Give you top level frame jQuery Object.
为了获得更多的向后兼容性,您可以使用类似于
window.parent.$('#frame2')
或者像这样的没有jQuery的东西:
window.parent.getElementById('#frame2')[attributeName]
一旦拥有了根iFrame对象,就可以继续进行常规的jQuery / DOM操作。
编辑 :这里是一个完整的工作和测试解决方案(Safari / Mac OS)。 以下仅突出显示更改:
displayPanel.html:
<head> <link rel="stylesheet" type="text/css" href="GridTest.css"> </head> <body> <script src="GridTest.js"> </script> <script> printInfo(); </script> <div id="label1"></div> <!--Added a div for displaying text --> </body>
GridTest.js:
function changeSquare() { var image = document.getElementById(this.id); //First get a reference to the second frame document var secondFrameDocument = window.top.document.getElementById('frame2').contentWindow.document; //Now set the value of the Div secondFrameDocument.getElementById('label1').textContent=this.id; // If image is currently green square, change to red, and vice versa if (image.src.match("http://www.clker.com/cliparts/b/d/4/F/W/N/green-square-button-md.png")) { image.src = "http://www.clker.com/cliparts/1/J/s/o/7/y/red-square-button-md.png"; } else { image.src = "http://www.clker.com/cliparts/b/d/4/F/W/N/green-square-button-md.png"; } currentDisplay = this.id; };
根据您的具体情况,您可能会遇到安全问题,特别是在Chrome中。 更好的解决方案可能是使用两个Div而不是iFrame。 这里有一个截图:
In your changeSquare method, try something like this:
var frame2 = $('#frame2', top.document) //Give you top level frame jQuery Object.
for more backwards compatibility, you can use something like:
window.parent.$('#frame2')
Or something like this for no jQuery:
window.parent.getElementById('#frame2')[attributeName]
Once you have the root iFrame object, you can proceed with regular jQuery/DOM manipulation.
EDIT: here is a fully working and tested solution (Safari/Mac OS). Only the changes are highlighted below:
displayPanel.html:
<head> <link rel="stylesheet" type="text/css" href="GridTest.css"> </head> <body> <script src="GridTest.js"> </script> <script> printInfo(); </script> <div id="label1"></div> <!--Added a div for displaying text --> </body>
GridTest.js:
function changeSquare() { var image = document.getElementById(this.id); //First get a reference to the second frame document var secondFrameDocument = window.top.document.getElementById('frame2').contentWindow.document; //Now set the value of the Div secondFrameDocument.getElementById('label1').textContent=this.id; // If image is currently green square, change to red, and vice versa if (image.src.match("http://www.clker.com/cliparts/b/d/4/F/W/N/green-square-button-md.png")) { image.src = "http://www.clker.com/cliparts/1/J/s/o/7/y/red-square-button-md.png"; } else { image.src = "http://www.clker.com/cliparts/b/d/4/F/W/N/green-square-button-md.png"; } currentDisplay = this.id; };
Depending upon your exact scenario, you may run into security issues, particularly with Chrome. A better solution would be to perhaps use two Divs instead of iFrames. Here's a screenshot:
相关问答
更多-
OpenID和Iframes(OpenID and Iframes)[2022-03-12]
尝试在弹出式窗口(window.open或)中运行您的登录。 这种方式window.top ==窗口,使网站不会iframed。 然后,当你回到你自己的身边时,你可以发送一个auth cookie和一个