I want to find out is it possible to deploy classic cloud service package (Microsoft.ClassicCompute) to Azure deployment slot with AZ powershell.
There is a classic service inside a resource group already created in Azure. A package that is going to be deployed is uploaded to a separate Storage Profile blob.
Currently, the webroles are deployed using REST API. An appropriate path to a package in the blob is specified in element of a post request and this works fine.
I am trying to do the same thing using AZ powershell, particulary, by calling New-AzResource cmdlet with '-PropertyObject' parameter specified like that:
#{
deploymentLabel = 'XXX';
configuration = '<?xml version=\"1.0\" encoding=\"utf-8\"?> .... ';
packageUrl = '{valid_url_to_package}';
....
}
but an error returns:
The request content was invalid and could not be deserialized: 'Could
not find member 'packageUrl' on object of type
'DeploymentSlotProperties'. Path 'properties.packageUrl'
If to remove 'packageUrl' property from the object and execute the cmdlet again an another error is shown up:
The deployment request is missing the package link.
Unfortunately, I cannot find any any information about format of '-PropertyObject' parameter. Or maybe there is a better way to deploy a package via AZ?
According to my research, Azure PowerShell Az module is used to manage Azure ARM resource. But Azure Cloud service is Classic resource. So we cannot deploy azure cloud service with az module. For more details, please refer to the document and issue. If you want to know to deploy Azure cloud service with PowerShell, please refer to https://github.com/MicrosoftDocs/azure-cloud-services-files/tree/master/Scripts/cloud-services-continuous-delivery
Related
I'm following the instructions here to create an azure static web app from the cloud shell, using the command:
az webapp up --location westindia --name static-webapp-test --html
Getting the following Unauthorized error :
The webapp 'static-webapp-test' doesn't exist Creating Resource group 'anubhav.das_rg_8008' ... Resource group creation complete Creating AppServicePlan 'anubhav.das_asp_4721' ... Operation returned an invalid status 'Unauthorized'
I have seen these type of errors like preventing the user from creation of resources due to role restrictions or access level restrictions in the subscription.
Please check your role (should be owner or contributor or user access administrator) and filters added in the Azure Active Directory.
It is recommended to use the latest version of CLI.
If you are using the older version run the below cmdlet to upgrade the CLI to latest version :
az upgrade --yes
I have followed the steps provided in the given documentation, we are able to create the static web app successfully :
Selected Azure Cloud Shell and given the following settings like my subscription, location, resource group name, storage account name, file share name for working on the cloud shell.
Cloned the git hub project to my azure account as you can see in below screenshot:
Also created another same type of application with the name you have given:
As I can see there is no issue in creation of static html web app though I have existing resource group using for working with cloud shell, it is creating new resource group for the web app purpose by using the given commands in the documentation and working good without any access restriction like authorization as my role belongs to Contributor.
I have a VM running in Azure which has ansible installed.
Is it possible to run ansible to find the tags associated with this VM (which ansible is running on)?
Furthermore Can it be done as part of a "lookup" expression?
E.g hosts: {{lookup(tag_name) }}
Elaborating Hassan Raza's suggestion:
This is Azure REST API reference and this is Tags REST API section and this REST API helps to get the entire set of tags on a resource. So you may just use this REST API to accomplish your requirement.
On the other hand, you can also leverage Az PowerShell to get the entire set of tags on a resource and this is that Az PowerShell cmdlet which is part of Az.Resources module so you need it this module imported as a pre-requisite. Again, you may just use this cmdlet from your local machine or from wherever you want to.
On the another hand, you may also create something called Azure Automation Runbook (in general words its a script that's created in Azure cloud under an Azure Automation account). So you may create an Azure Automation account and then a simple runbook to get the entire set of tags on a resource.
The solution we went with was to use the Ansible azure_rm_virtualmachine_info_module :
https://docs.ansible.com/ansible/latest/collections/azure/azcollection/azure_rm_virtualmachine_info_module.html
This returns azure tag info.
I want to configure the authentication for my Azure function via code, be it powershell, ARM template or an API? is this possible?
i'm under the impression that an Azure Function is nothing more then an App Service so i would assume it resolve around there.
https://learn.microsoft.com/en-us/powershell/module/az.websites/?view=azps-2.0.0#app_service - there doesn't seem to be anything in the powershell.
https://resources.azure.com/ doesn't seem to give much information.
Here is some documentation on how to use managed identities for App Service and Azure Functions: https://learn.microsoft.com/en-us/azure/app-service/overview-managed-identity
You could create an PowerShell function app with MSI (Managed Service Identity) enable in a consumption plan. Here is some documentation (https://azure.microsoft.com/en-us/resources/templates/101-functions-managed-identity/) on how to do that.
Once the function app is created, you can grant it access to a given resource https://learn.microsoft.com/en-us/powershell/module/az.resources/new-azroleassignment?view=azps-2.0.0#examples
Lastly, the PowerShell function app comes with a profile.ps1 which contains code to authenticate against Azure via MSI out the box.
# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
if ($env:MSI_SECRET -and (Get-Module -ListAvailable Az.Accounts)) {
Connect-AzAccount -Identity
}
Please give it a try and let us know if you run into any issues.
Azure Functions Authentication are still pending. Currently AFAIK there is not a way to add authentication via code except with the Function Host Keys
You can track the issue here in Github
Using terraform is a really good way of configuring these, a good example is below. Also az CLI 'az webapp auth' seems to have really good support now. PowerShell still seems to be lagging behind.
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app
I have an ARM Template stored in Azure Templates.
Is there a way to reference this template from script (either in Azure Cloud Shell or PowerShell/CLI on local machine)? Right now it seems the only way to deploy the template is through the Azure portal UI.
Update
I wanted to clarify what I am asking. I am asking specifically about Azure Templates (Preview) service. It seems that once you store a template in Templates service the only way to access it is through the Azure portal.
For example, let's say I am creating a VM in Azure portal. I can save the ARM template to Templates service as shown in the images below.
You can click on Download Template and parameters link, on next page click on Add to library to save the template to Templates service (Templates service can be found in Azure portal through All Service > filter for "Templates").
I was doing the course on edX.org: Automating Azure Workloads and it was talking about this service, that's why I became interested in this service.
You can deploy a template with every possible mean you mention. Not only the portal UI.
There is documentation here - section Deploy a template from external reosurce (also explains how to deploy from a private resource using SAS:
New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup `
-TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json `
-storageAccountType Standard_GRS
The referenced documentation also provides sample for use with Cloud Shell.
Is it possible to export the JSON definition for an existing app service in Azure?
Ie this json object: https://learn.microsoft.com/en-us/azure/templates/microsoft.web/sites
The app service was created using the Azure Portal UI and I want to recreate it using the Azure CLI command line.
You could use az group export --name *** >test.json to capture a resource group as a template. Please refer to this link.
But currently resource type Microsoft.Web/sites does not support export, please refer to this feedback.
Note: If also could find the error log on Azure Portal.