AzureRm Add-AzureCertificate equivalent in Az - azure

Ahead of the deprecation of the AzureRM powershell cmdlets later this year I am updating some of our infrastructure scripts to use the Az powershell cmdlets rather than AzureRM.
One of our scripts uploads SSL certificates to Azure Cloud Service(Classic) resources using Add-AzureCertificate:
Add-AzCertificate -ServiceName $serviceName -CertToDeploy $certObject
where $certObject is a X509Certificate2 object.
What is the equivalent cmdlet in the Az module? Add-AzCertificate does not exist.
On the Cloud Service documentation page where it details configuring SSL, only certificate upload via the Azure portal is shown.

As the comment from #Alex AIT, before call the AzureRM commands, you can run Enable-AzureRmAlias cmdlet which enables a compatibility mode through aliases, to allow you to use existing scripts with minimal modification while working towards a full migration to Az. For more information, you could refer to Migrate existing scripts to Az.
Also, to call Azure Cloud Service(Classic) resources, you still need Azure modules. View this example- Az / AzureRM / Legacy Azure Powershell Conflicts.

Related

Job Suspended Run Login-AzureRmAccount to login using Azure AutomationAccounts System Managed Identity

I am trying to shutdown the VM using Azure Automation Account System Managed identity option.
However I am ending up with below error.
As per the other articles it is mentioned to upgrade the module Update-ModulesInAutomationToLatestVersion but I could not update due to below error. I am not sure what is the issue in the script. Same script works with AzureRunAsConnection option without issues ( script ).I even checked with simple login with System Managed Identity it successfully login and fetches the resource group names.
I have tested the above shared script in my automation account. Below are
the couple of observations:
You need to use Connect-AzureRMAccount -Identity cmdlet instead of 'connect-AzAccount` to connect to your subscription because the rest of the script that you have written using Azure RM cmdlets.
If we use AzureRM cmdlets in your run book script the job is getting suspended stating that Azure RM is going to retired and suggesting us to use Az Module in your workflow.
You can refer to this documentation on how to migrate your PowerShell scripts automatically from AzureRM to AZ modules.
If you want to perform start/stop on your virtual Machines you can leverage the Azure Automation start/stop during the off hours feature.
According to the MICROSOFT DOCUMENTATION and looking at your script the Azure Rm module is not supported and it has been updated to the latest version of Az module.
For more information please refer the below links:-
MICROSOFT DOCUMENT|Using a system-assigned managed identity for an Azure Automation account & Troubleshoot runbook issue.

Az Powershell commands not working for "Cloud service (classic)"

I'm simply trying to extract the below information using Az PowerShell.
Resource on portal
Already tried the below commands
Get-AzCloudService -ResourceGroupName "testCosmosDB" # it gives no result.
Get-AzCloudService -ResourceGroupName "testCosmosDB" -CloudServiceName "testnameon" # as shown below.
The reason you're getting this error is because Az PowerShell module only support Cloud Services (Extended Support) and not Cloud Services (Classic).
One option for you is to migrate your classic Cloud Services to Cloud Services (Extended Support). You can learn more about the migration here: https://learn.microsoft.com/en-us/azure/cloud-services-extended-support/overview#migration-to-azure-resource-manager.
Another option (not sure if it is even viable) is to make use of really old version of Azure PowerShell (even before AzureRM) which has support for classic resources.

Manage Microsoft.ClassicCompute/domainNames with Az PowerShell module

I have a classic Compute resource. I need to move some old deployment code that used Azure.Service module to Az and I was wondering, is there a way to manage that with Az or something up to date?
I have to upload some .cspkg and some .cscfg files. There is more to it, but basically, this was done using this cmdlet and the related ones, Set, Get etc.
I used Az.Resources' cmdlet New-AzResource to create it:
New-AzResource `
-Location 'location' `
-ResourceGroupName 'rgName' `
-ResourceType 'Microsoft.ClassicCompute/domainNames' `
-ResourceName 'rName' `
-ApiVersion '2018-06-01'
What cmdlets could I use to manage this resource?
In your case, you could use Az.CloudService module commands, to upload some .cspkg and some .cscfg files, use New-AzCloudService with parameters -PackageUrl and -ConfigurationUrl(or -Configuration).
The command New-AzCloudService can Create or update a cloud service, i.e. New, Set operations, to do Get operation, use Get-AzCloudService command.
Anyway, see here for all the commands to manage Microsoft.ClassicCompute/domainNames i.e. Cloud service, use them depends on your requirement.
Update:
In this case, looks you could not migrate your commands to Az module, Az.CloudService is for the new Cloud Service(extended support) which is ARM(Azure Resource Manager) based, and it is in the preview version, see Deploy a Cloud Service (extended support) using Azure PowerShell, some features might not be supported, I think the error was caused by this.
What you are using is Cloud Service(classic), it is ASM(Azure Service Management) based, the new Az module is just for ARM resources.
So in your case, you may need to continue to use Azure.Service module, or you can migrate the ASM to ARM i.e. Cloud Service(classic) to Cloud Service(extended support), see Migration to Azure Resource Manager, but not recommend you to use it in the production environment as it is in preview.

How to implement Update-AzSqlServerVulnerabilityAssessmentSetting using AzureRM

I have an Az script that sets up Advanced Data Security for my Azure SQL Databases/Servers.
Unfortunately, Az cannot run in Azure Devops, so I translated the script to AzureRM. The script leaves Advanced Data Security in a "Partially Configured" state, due to the Azure SQL Server's VULNERABILITY ASSESSMENT SETTINGS not being set.
What is the AzureRM equivalent of Update-AzSqlServerVulnerabilityAssessmentSetting
I tried
Update-AzSqlServerVulnerabilityAssessmentSetting
to:
Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings
However, only the database gets configured and this leave the Server unconfigured.
They are not an equivalent, the AzureRm module was deprecated and will not be updated.
Unfortunately, Az cannot run in Azure Devops, so I translated the script to AzureRM.
As I know, the Task version with 4.*(preview) supports Az module. I tried it here.
If you want to AzureRm module to update Azure SQL Vulnerability Assessment Setting, you just can use command "update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings" to configure all database in one server, AzureRM does not provide command to enable customers to directly configure Azure SQL server. For more details, please refer to the blog.
Get-AzureRmSqlDatabase -ResourceGroupName $params.rgname -ServerName $params.serverName`
| where {$_.DatabaseName -ne "master"} `
| Update-AzureRmSqlDatabaseVulnerabilityAssessmentSettings `
-RecurringScansInterval Weekly `
-NotificationEmail $scanNotificationEmail `
-EmailAdmins $true"

How can I run Azure's Get-AzureServiceAntimalwareConfig cmdlet equivalent in the new Azure Cloud Power Shell 'Az'

In Azure Power Shell within the Azure cmdlet module there is a cmdlet called "Get-AzureServiceAntimalwareConfig". I want to run the equivalent cmdlet but from the new PowerShell Az cmdlet module. How can I find the equivalent cmdlet for 'Az'? Do I need to install a cmdlet module that isn't already installed by default? I'm using Azure Cloud Shell.
It seems there is no equivalent command of Get-AzureServiceAntimalwareConfig in Az powershell module.
The command is used to get the antimalware configuration and monitoring configuration details associated with the Microsoft Antimalware extension for a cloud service. Cloud service is a classic(ASM) service, but the Az powershell module is for ARM.

Resources