azure-powershell

Login-AzureRmAccount return subscription but Get-AzureSubscription return empty

佐手、 提交于 2019-12-22 04:11:11
问题 I am able to login successfully with the Login-AzureRmAccount . Also I am able to see my subscription in the return value of Login-AzureRmAccount. But after login, if I type Get-AzureSubscription it return empty. Find the below screenshot 回答1: Well, you need to use Get-AzureRmSubscription (RM), since you are using the cmdlet for ASM mode, not ARM. There are 2 deployment modes in Azure, ASM (old) and ARM (new one). 回答2: Expanding on the other answers. In Azure there is two deployment models.

Azure Web App: Delete all files before publish

社会主义新天地 提交于 2019-12-21 20:28:44
问题 When publishing to our Azure Web App using the following Powershell script, we often have issues whereby files from the previous publish cause runtime errors. param($websiteName, $packOutput) $website = Get-AzureWebsite -Name $websiteName # get the scm url to use with MSDeploy. By default this will be the second in the array $msdeployurl = $website.EnabledHostNames[1] $publishProperties = @{'WebPublishMethod'='MSDeploy'; 'MSDeployServiceUrl'=$msdeployurl; 'DeployIisAppPath'=$website.Name;

Login-AzureRmAccount and Select-AzureRmSubscription

孤者浪人 提交于 2019-12-20 03:11:15
问题 I have installed AzureRm and Azure module on Windows server 2012 R2. I can run other cmdlets from this module (eg.AddAzureRmAccount, Get-AzureRmSubscription) but Login-AzureRmAccount and Select-AzureRmSubscription are throwing not recognized error: Login-AzureRmAccount : The term 'Login-AzureRmAccount' 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.

Authenticating with Azure Active Directory on powershell

情到浓时终转凉″ 提交于 2019-12-18 16:45:12
问题 I am attempting to explore the features of the Azure Active Directory V2 PowerShell Module I have an Azure Account, and I have set up an Active Directory with multiple users. My first goal is simple: show me the list of users. So I type: Connect-AzureAD I am presented with a dialog and type in my user account and password. It returns on object of type Microsoft.Open.Azure.AD.CommonLibrary.PSAzureContext . I then type Get-AzureADUser And the error is: Get-AzureADUser : Error occurred while

Use Automation RunAs service principal to connect to Azure Analysis Services and process

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-18 09:28:28
问题 TL;DR In summary the steps are: Use the correct code (the last code in this post) Manually add your app id in SSMS as either a server administrator or a database administrator and then you can process an Azure Analysis Services cube from an Azure Automation Account without needing to create another seperate service account Actual Question: I am trying to process an Azure Analysis Services cube using the Azure Automation RunAs Service Principal. This is run within an Azure automation account

Azure AD - enable the service principal as a an application administrator

久未见 提交于 2019-12-18 07:04:43
问题 I'd like to know how to have a ServicePrincipal in Azure AD that will be able to alter app registrations that it doesn't own , like remove an app or rotate its keys. I was told that if SP has "Application administrator" role then it should have enough permissions to do so. So how would I be able to achieve this in Powershell? 回答1: I think you are looking for the Add-AzureADDirectoryRoleMember PowerShell cmdlet. Here is an example: # Fetch role instance $role = Get-AzureADDirectoryRole | Where

How to run Azure CLI commands using python?

╄→гoц情女王★ 提交于 2019-12-18 06:49:30
问题 I want to use Azure CLI to get the list of all the VMs in my resource group. But I want to implement the same using a python script. For example, I will use the following command in Azure CLI to list the VMs in my resource group: " az vm list -g MyResourceGroup " But, I want the python script to do the same, where I just have to incorporate the CLI command in the python program. 回答1: I have been implementing this over the last couple days. The method that @cbehrenberg provides is mostly what

KeyVault generated certificate with exportable private key

折月煮酒 提交于 2019-12-17 22:54:10
问题 I'm attempting to create a self signed certificate in KeyVault using the "Self" issuer. $policy = New-AzureKeyVaultCertificatePolicy -SubjectName "CN=$($certificateName)" -IssuerName "Self" -ValidityInMonths 12 $policy.Exportable = $true Add-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -CertificatePolicy $policy However, when getting the certificate back it doesn't appear to have a private key. Creating certificates directly in KeyVault doesn't seem hugely covered

New-PSSession in an Azure-runbook (ARM)

雨燕双飞 提交于 2019-12-14 03:54:17
问题 For an Azure VM in the classic portal (ASM) I was able to obtain the required credentials with Get-AutomationPSCredential and the -ConnectionURI with Connect-AzureVM.ps1. With these two parameters I was able to successfully execute a New-PSSession in an Azure-runbook. Q What am I supposed to do to open a PS-Session in an Azure-runbook to an Azure-VM (ARM)? Update command in runbook (ARM) $vmSession = New-PSSession -ConnectionUri 'https://xxx.yyy.cloudapp.azure.com:5985' -Credential $creds

Azure PowerShell script does not work when change to a different Azure Subscription

流过昼夜 提交于 2019-12-14 02:25:19
问题 I am experiencing a very strange problem. I recently switched Azure subscription from free trial to pay-as-you-go . The PowerShell script i wrote to create Azure Resource Group , Azure Data Factory , Azure Active Directory App Azure SQL Server , Azure SQL Database does not work. below is the sample code from script and error messages New-AzResourceGroup Test2ResourceGroupName2 -location 'westeurope' $AzADAppName = "TestADApp1" $AzADAppUri = "https://test.com/active-directory-app"