Deploy a Cloud Services (extended support) using New-AzCloudService - azure

I'm trying to understand how to deploy an Azure Cloud Services (extended support) using the powershell command New-AzCloudService.
I already deployed the cloud service using Visual Studio and everything went well, but when I try to deploy it using the following command
New-AzCloudService
-Name $ServiceName
-ResourceGroupName $ResourceGroupName
-Location $Location
-ConfigurationFile $CscfgFilePath
-DefinitionFile $CsdefFilePath
-PackageFile $CspkgFilePath
-StorageAccount $StorageAccount
I receive the error below:
A Cloud Service resource with name: <service_name> already exists in Resource Group:
<resource_group_name>. Please try another name.
Looking at the New-AzCloudService documentation here it states: Create or update a cloud service.
What I'm doing wrong?

Related

How to enable "MySQL in App" in an App Service using the Azure CLI

I have created an App Service in Azure using the CLI. But, I cannot see any CLI options to enable "MySQL in App". I have checked here: https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest and see no mention of it.
What is the CLI to enable it? Or, failing that, if there is no CLI command, using PowerShell?
I know your question is related to az cli but I don't know if possible using that myself.
I can confirm however that the following works using PowerShell (Az module):
$app = Get-AzWebApp -ResourceGroupName <Resource Group Name> -Name <Web App Name>
$app.SiteConfig.LocalMySqlEnabled = $true
$app | Set-AzWebApp
Hope this helps until someone can confirm for az cli specifically.

Powershell Script continues to ask me to use Select-AzureSubscription although I have called it

I have an Azure runbook where I am trying to deallocate VMs. When I run the runbook I get the error
Stop-AzureVM : No default subscription has been designated. Use Select-AzureSubscription -Default <subscriptionName> to
set the default subscription.
I have used the below in my script.
Add-AzureRmAccount
Select-AzureRMSubscription
After calling the select, it prints out
PSComputerName : localhost
PSSourceJobInstanceId :
Account :
Environment :
Subscription :
Tenant :
with the correct subscrption and tenant information so it seems the select is working correctly, but for some reason I still cannot use the Stop-AzureVM cmdlet.
Any ideas?
The command Stop-AzureVM is Azure Service Management PowerShell command. It just can be used to stop Azure classic VM. But the command Add-AzureRmAccount is Azure Resource Management PowerShell command. After running the command, we just can manage Azure Resource Management resources. For more details, please refer to here and here.
So with Azure ARM VM, please use the command Stop-AzureRmVM to stop it. Meanwhile, regarding how to stop Azure classic VM, please refer to the following steps
Create Azure Classic Run As Account
Script
$ConnectionAssetName = "AzureClassicRunAsConnection"
# Get the connection
$Conn = Get-AutomationConnection -Name $ConnectionAssetName
# Authenticate to Azure with certificate
$CertificateAssetName = $Conn.CertificateAssetName
$AzureCert = Get-AutomationCertificate -Name $CertificateAssetName
Set-AzureSubscription -SubscriptionName $Conn.SubscriptionName -SubscriptionId $Conn.SubscriptionID -Certificate $AzureCert
Select-AzureSubscription -SubscriptionId $Conn.SubscriptionID
#stop VM
Stop-AzureVM -ServiceName "ContosoService01" -Name "MyVM" -Force
Besides, regarding how to check if the VM is classic, please refer to the blog
Try Running the below :
Get-Module AzureRm.Profile -ListAvailable
This issue might occur when there is multiple instances of the module. If there are multiple instance remove the older modules and retain the new module.
To remove the old module : Uninstall-Module -Name AzureRm.Profile -RequiredVersion 4.6.0#(olderversion if you have any)

'The term 'Set-AzureRmDataFactoryV2' is not recognized as the name of a cmdlet' error in Pipeline Azure Devops

Azure Powershell AZ module still does not work in azure devops pipeline?
I get this error when I try powershell version 4+ and the agent is 2017 (also tried windows 2019)
#Install-Module -Name Az -AllowClobber -Scope CurrentUser (is this needed? I tried with and #without and it fails)
Set-AzureRmDataFactoryV2 -ResourceGroupName "myRG" -Name "LLmenADF1" -Location "North Europe"
If you are using Powershell Az module, then the cmdlet is:
Set-AzDataFactoryV2
Your cmdlet makes reference to the old library, AzureRM. To get the same cmdlet when migrating from one library to another, just replace AzureRM with Az.
Hope this helped!
#Martin Esteban Zurita has the correct recommended solution to migrate to Az commands
For those that can't/won't for any reason, just select Version 3 of the Azure Powershell task to work with AzureRM commands.

What is the equivalent of "az functionapp" in AzureRM?

My deployment script uses PowerShell with the AzureRM module. I am trying to find the equivalent of the following Azure CLI call. That call creates an Azure Function based on a Docker image.
az functionapp create --name <app_name> --storage-account <storage_name> --resource-group myResourceGroup --plan myPremiumPlan --deployment-container-image-name <docker-id>/mydockerimage:v1.0.0
Anybody has an idea what is the PowerShell/AzureRM equivalent of "az functionapp create"?
If your ideal goal is to deploy a function app, there are multiple ways to create one.
You can use the below AzureRm command to provision / create a new Function App
New-AzureRmResource -ResourceType ‘Microsoft.Web/Sites’ -ResourceName $functionAppName -kind ‘functionapp’ -Location $location -ResourceGroupName $resourceGroupName -Properties #{} -force
Or You can use a ARM Template to deploy a function app - Details
Or you can use Zip Deploy to deploy your function app. -
As HariHaran said, there are several ways to create new function app. But if you want to create function based on docker image, it may be difficult to implement if use "New-AzureRmResource". So I think you can install az module in powershell, you can continue use "az functionapp create" commmand, you can refer to this tutorial to install it. But az module will not be compatible with AzureRM, so we'd better uninstall AzureRM before that, you can refer to this page about the compatible of az module and AzureRM.
You can use the New-AzFunctionApp cmdlet which is part of the Az.Functions module. This module is currently in Preview.
# First install PowerShell 6 or 7 from https://github.com/PowerShell/PowerShell/releases
# To install the Az.Functions module, Open PowerShell and run:
Install-Module -Name Az.Functions -AllowPrerelease
Alternatively, you can download it from https://www.powershellgallery.com/packages/Az.Functions/0.0.1-preview
For feedback and requests, please file an issue at https://github.com/Azure/azure-powershell/issues. Make sure you include in the title [Az.Functions]. Thanks!

how to read service configuration (.cscfg) of a cloud service created on RM subscription

I have a cloud service (classic) created on RM subscription. I need to read its service config (.cscfg), update the config and redrploy it back to the cloud service.
I did it using get-azuredeploy command on Classic, but this command doesnt work on RM subscription.
does anyone know how to get service config from RM subscription?
Try the command below, the $slot.Properties.configuration should be that.
$slot = Get-AzureRmResource -ResourceGroupName <ResourceGroupName> -ResourceType Microsoft.ClassicCompute/domainNames/slots -ResourceName "xxxxx" -ApiVersion 2016-04-01
$slot.Properties.configuration

Resources