如果在测试运行 Azure Function App 出现 “The term 'Get-AzSubscription' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again” 那么就得加上注册、导入 PowerShellGet 模块 的命令,当测试运行成功后,再注释掉就可以了。
# Input bindings are passed in via param block. param($Timer) $subscription_Id = "Your Subscription_Id " $tenant_Id = "Your Tenant Id " $Resource_Name = "Web_Test_VM_RG" $VM_Name = "cnbateblog-vm" #Install-Module #Import-Module Select-AzSubscription -SubscriptionID $subscription_Id -TenantID $tenant_Id Start-AzVM -ResourceGroupName $Resource_Name -Name $VM_Name保存后,我们可以尝试测试代码
我们可以从 VM 的活动日志中看到当前VM的状态的变化
19:15停止VM
23:20 手动触发 TimeTrigger 启动VM
Bingo!!!!!完成。大家可以自行尝试操作一下