获取当前的订阅ID

时间:2019-05-04 07:34:26

标签: azure powershell azure-powershell

使用Powershell Azure模块,是否可以获取活动的订阅ID?

我可以使用db设置订阅,但是import csv def boo(): stock = input("Enter Stock #: ") # Generate data for each column to fill in to the output file. VIN = input("Enter Full VIN: ") # Each line asks the user to add data do the line. make = input("Enter Make: ") model = input("Enter Model: ") year = input("Enter Year: ") l8v = input("Enter L8V: ") print(stock, VIN, make, model, year, l8v) # Prints the line of user data input4 = input( "Append to inventory list? Y/N || anything else to exit") # Asks user to append the data to the output file. if input4 == "Y" or input4 == "y": with open('INV.csv', 'a', newline='') as outfile: # Pull up a separate csv to write to, an output for collected data w = csv.writer(outfile) w.writerow([stock, VIN, make, model, year, l8v]) # Need to write the previously pulled up line to new csv print("INVENTORY UPDATED") user_input = input('Do you want to add one more entry: Enter [Y/N]') if user_input.lower() == 'y': boo() else: exit() boo() 返回的订阅名称没有特定的Set-AzContext

Get-AzContext返回订阅列表,但不返回活动订阅。

1 个答案:

答案 0 :(得分:2)

您可以使用以下命令执行此操作:

(Get-AzContext).Subscription.id