标签: azure-powershell

使用Azure Power Shell将应用程序设置添加到现有Azure Web应用程序

我想编写一个使用azure power shell运行的脚本来自动添加Web应用程序配置

Azure> MyWebApp>应用程序设置>应用程序设置

它看起来像key ="value"

我写这个脚本

###########################
# MyApp Config Automation #
###########################

#Begin

$subscriptionName="MySubscriptionName"
$webSiteName="MyWebAppName"
$storageAccountName="StorageAccountName"
########################################
$userName = "myaccount@outlook.com"
$securePassword = ConvertTo-SecureString -String "mypass" -AsPlainText -Force
#####################################
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword)
#####################################
Add-AzureAccount -Credential $cred 
Select-AzureSubscription -SubscriptionName $subscriptionName -Default
#####################################
Get-AzureWebsite -Name $webSiteName

#End
Run Code Online (Sandbox Code Playgroud)

但我知道上面的脚本只是获取我的Web应用程序,现在我需要访问MyWebApp>应用程序设置>应用程序设置并给出我的新应用程序设置的脚本文件/数组,并检查脚本是否有任何新的应用程序设置键它会将它添加到App Settings,如果有任何现有的键,它将覆盖它的值.什么是步骤或APIS或我能用天蓝色电源壳做到这一点?

编辑:此脚本可以自动创建新的Web应用程序并向其添加应用程序设置:

##############################################
# Creating website and Adding Configs Script #
##############################################

$webSiteName="mywebsite"
$storageAccountName="storageaccount"
$subscriptionName="mysubsc"
$userName = "myaccount"
$securePassword = ConvertTo-SecureString -String "mypass" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential($userName, $securePassword) …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-powershell

35
推荐指数
3
解决办法
2万
查看次数

安装模块:术语"安装模块"不被识别为cmdlet的名称

我试图Install-Module Azure在PowerShell中安装Azure .我收到以下错误:

PS C:\Windows\system32> Install-Module Azure
Install-Module : The term 'Install-Module' 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 corre
ct and try again.
At line:1 char:1
+ Install-Module Azure
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)

为什么PS无法识别基本的安装模块?没有这个,我甚至无法安装Azure.我该怎么办?

powershell azure azure-virtual-machine azure-powershell

33
推荐指数
4
解决办法
15万
查看次数

如何查找当前的Azure RM订阅

在Azure Classic/Service Management中,Get-AzureSubscription将在租户中提供订阅列表,其中包含哪个订阅是最新的.

还有一个Get-AzureSubscription -Current标志可以为您提供当前订阅.

有没有办法在AzureRM.Profile中找到当前订阅?

azure azure-powershell

23
推荐指数
2
解决办法
2万
查看次数

Azure Powershell脚本,用于交换Azure App Service(网站)部署插槽

我正在寻找一种方法来使用Azure PowerShell命令为Azure应用服务(以前的Azure网站)进行部署交换.我见过的所有帖子都说使用命令

Move-Deployment -ServiceName
Run Code Online (Sandbox Code Playgroud)

但这似乎只适用于云服务以及生产和分段预定义插槽之间的交换.

我有一个我已定义的部署插槽的网站,我可以使用以下命令获取有关该网站的信息,但我不知道如何交换它:

Get-AzureWebsite -Name "sitenamehere" -Slot test
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-powershell

20
推荐指数
1
解决办法
3606
查看次数

如何找到Azure PowerShell版本?

我需要通过cmdlet代码找到已安装的Azure PowerShell版本.如何找到Azure PowerShell版本?

注意:除了cmdlet代码之外,也欢迎使用.

powershell cmdlets version azure azure-powershell

19
推荐指数
4
解决办法
3万
查看次数

检查Azure资源组是否存在 - Azure Powershell

我正在尝试验证ResourceGroup是否存在所以我认为以下代码应返回true或false,但它不输出任何内容.

$RSGtest = Find-AzureRmResource | Format-List ResourceGroupName | get-unique
$RSGtest -Match "$myResourceGroupName"
Run Code Online (Sandbox Code Playgroud)

为什么我没有得到任何输出?

powershell azure-powershell azure-resource-manager

15
推荐指数
2
解决办法
9593
查看次数

Azure Powershell:Login-AzureRmAccount的相反命令是什么(以前是Clear-AzureProfile)

我有各种脚本,我曾经在包装器中运行,允许我处理诸如检查我有一个有效连接之类的事情,并询问用户当前选择的连接/订阅是否是他们想要在运行之前运行脚本的那个等等

经典命令具有Clear-AzureProfile,它允许我从脚本运行它并有效地断开连接,以便在不调用Add-AzureAccount的情况下不能再次使用它.

使用RM cmdlet我只能找到Login-AzureRmAccount但是一旦我登录了......我该如何调用logout?

似乎没有Logout-AzureRMAccount或Remove-AzureRMAccount,Clear-AzureProfile无效.

我运行一个开发工作站并连接到几个不同的客户端订阅,所以希望能够破坏连接,而不是只是在其顶部调用另一个登录(如果登录失败,我仍然会设置旧的连接,这对于我)

我刚刚记录了这个:https://msdn.microsoft.com/en-us/library/mt619248.aspx,因为它看起来可能缺少命令的文档

azure-powershell

14
推荐指数
3
解决办法
1万
查看次数

致命:无法读取“https://OrganizationName@dev.azure.com”的密码:终端提示已禁用

使用 Azure Pipelines PowerShell 任务构建时,我试图将develop分支合并到分支master

但是在执行命令时git push,我收到此错误:

致命:无法读取“ https://OrganizationName@dev.azure.com ”的密码:终端提示已禁用

代码存储库是“Azure Repos Git”。

git checkout -b master
git config --global user.email "xxxxxxx@xxxx.xxx"
git config --global user.name "xxxxx"
git merge origin/develop 
git push origin master
Run Code Online (Sandbox Code Playgroud)

在引用了一些 URL 之后,我创建了个人访问令牌,并将推送命令修改为git push https://PAT@dev.azure.com/OrganizationName,但它仍然无法正常工作。

如果您找到解决此问题的方法,请告诉我。

git azure-powershell azure-devops azure-pipelines-build-task azure-pipelines

14
推荐指数
2
解决办法
2万
查看次数

关于 cmdlet 'Get-AzKeyVaultSecret' SecretValueText 中的重大更改的警告已弃用 Az4.6.1

我今天将 Az Powershell 升级到 4.6.1 并开始看到以下警告。我的问题是我应该如何处理这个警告?我可以将警告静音,但这根本无法帮助我为这一重大变化做好准备。我检查了 Az 4.6.1 Microsoft 文档,他们告诉我我应该仍然使用 SecretValueText 并且没有提供关于弃用或任何其他获取秘密值的替代方法的类似警告。那么我使用 SecretValueText 读取 KeyVault 机密的 powershell 的更新路径是什么?

WARNING: Breaking changes in the cmdlet 'Get-AzKeyVaultSecret' :
WARNING:  - "The output type 'Microsoft.Azure.Commands.KeyVault.Models.PSKeyVaultSecret' is changing" 
- The following properties in the output type are being deprecated :
 'SecretValueText'
WARNING: Note :The change is expected to take effect from the version :  '3.0.0'
WARNING:  - "The output type 'Microsoft.Azure.Commands.KeyVault.Models.PSDeletedKeyVaultSecret' is changing"
 - The following properties in the output type are being …
Run Code Online (Sandbox Code Playgroud)

azure azure-powershell

14
推荐指数
4
解决办法
6854
查看次数

KeyVault生成带有可导出私钥的证书

我正在尝试使用"Self"发行者 KeyVault中创建自签名证书.

$policy = New-AzureKeyVaultCertificatePolicy -SubjectName "CN=$($certificateName)" -IssuerName "Self" -ValidityInMonths 12 

$policy.Exportable = $true

Add-AzureKeyVaultCertificate -VaultName $vaultName -Name $certificateName -CertificatePolicy $policy
Run Code Online (Sandbox Code Playgroud)

但是,当获得证书时,它似乎没有私钥.

直接在KeyVault中创建证书似乎没有在线覆盖,在深入研究PowerShell cmdlet的其余API文档和源代码之后,我很难过.

我希望这是我错过的一些简单的事情,因为我希望避免在本地创建证书.

powershell x509 azure-powershell private-key azure-keyvault

13
推荐指数
1
解决办法
4848
查看次数