I'm trying to figure out if resources exist in Azure by using their resource ID. The Azure CLI command would be az resource show $resourceID. My application is in NodeJS.
Is there some equivalent in NodeJS I can use in my application? If not, is there another way to show a resource exists (information populates) or does not exist (null fields) in NodeJS?
Ultimately want to return true (exists) or false (does not exist).
To access Azure from your application, you can use their SDK. It uses similar terminology to Azure CLI. For your specific command, I believe checkExistenceById is what you are looking for.
Follow the installation instructions and learn the docs to see how to integrate the SDK into your app:
$ npm install azure-arm-resource
Related
Is there any way to configure the deployment center of a function, as below, using the az cli?
I tried to use az functionapp deployment source config, but I didn't find any parameter to put the password and user.
According to the docs you have parameters available to provide the authentication information:
https://docs.azure.cn/en-us/cli/functionapp/deployment/source?view=azure-cli-latest#az-functionapp-deployment-source-config
[--private-repo-password]
[--private-repo-username]
However I don't get these as options when using the Azure CLI -h (not even in the latest version in cloud shell). Not sure if the auto-complete is just failing to parse them or they're not available at all.
I tried to create an azure function using following link in Ubuntu system(16.04).
[azure function][2]
Deployment using arm template and create a local azure function using vs code.
Folder contains following files
LocalFunctionProj.csproj, HttpExample.cs, host.json, local.settings.json
azure function is created successfully in portal after deployment.But when i tried to publish the local azure function ,it shows an error Can't find app with name "HttpExample" while using following command
func azure functionapp publish HttpExample
Is anything wrong in my step.
Also i tried this command after 30 mnt when function created in portal
screen shot
I had a similar issue when I followed a tutorial about Azure Functions Core Tools from Microsoft Learning.
In my case, I had the error Can't find app with name X, because I had a wrong subscription set in my local Azure CLI. The command from below changes subscription for the one that is created with "Microsoft Learning Sandbox". Note that, in your case, the name of the subscription can be different.
az account set --subscription "Concierge Subscription"
If it's not the issue, your question suggests that your function app name should be HttpExample. You need to ensure beforehand that there's a function app with such a name in the subscription you are logged into with Azure CLI.
Moreover, there is a ProvisioningState: Failed in the screenshot, which could also be an issue.
If you want to publish the local app into azure ,you must create the functional app before in azure portal.Also the name of the azure function is portal should be same as the local azure app.otherwise you can't publish the app.
I have a most of my Azure infrastructure managed with Terraform.
However, I am quickly finding that a lot of the small details are missing.
e.g. client secrets aren't fully supported https://github.com/terraform-providers/terraform-provider-azuread/issues/95
It doesn't seem possible to add an Active Directory Provider to APIM
How Do I Add Active Directory To APIM Using Terraform?
Creating the APIM leaves demo products on it that can't be removed
How Can I Remove Demo Products From APIM Created With Terraform?
etc, etc.
Solutions to these seems to be utilising the cli
e.g. https://learn.microsoft.com/en-us/cli/azure/ad/app/permission?view=azure-cli-latest#az-ad-app-permission-add
Or falling back to the REST API:
e.g.
https://learn.microsoft.com/en-us/rest/api/apimanagement/2019-01-01/apis/delete
How can I mix terraform with the CLI and REST API?
Can they be embedded in terraform?
Or do I just run some commands to run them after terraform has finished?
Is there a way to do these commands in a cross platform way?
Will running the CLI and REST API after terraform cause the state to be wrong and likely cause problems the next time terraform is run?
How can I mix terraform with the CLI and REST API?
You can use the Terraform provisioner local-exec or remote-exec. In these ways, you can run the script with CLI commands or the REST API. For more details, see local-exec and remote-exec. But you need to take care of them. These two ways just run the scripts and display the output, but they do not have the outputs.
If you want to use the result of the script in the same Terraform file for other resources, you need to use the Terraform external data source, see the details here.
Update:
Here is an example.
Bash script file vmTags.sh:
#!/bin/bash
az vm show -d -g myGroup -n myVM --query tags
Terraform external data source:
data "external" "test" {
program = ["/bin/bash", "./vmTags.sh"]
}
output "value" {
value = "${data.external.test.result}"
}
How can i find the app, whose credentials were used to launch a vm in azure. I am able to use the compute client to get admin_username attached to a VM but it does not solve my use case as a user can give any username while launching it.
compute_client = ComputeManagementClient(credentials, subscription_id)
vm_details = compute_client.virtual_machines.get(resource_group_name= <resource_group>, vm_name=<vm_name>, expand='instanceView')
username = vm_details.os_profile.admin_username
Is the app_name stored as a vm property anywhere that can be accessed via azure-sdk for python?
First, please clarify "launch". Do you mean initial deployment, or starting an already existing VM which was off? Or both :)?
I do believe that this information is not part of the VM, but will be considered an event of ARM. Then, this will be available part of the Activity Log:
https://learn.microsoft.com/en-us/azure/monitoring-and-diagnostics/monitoring-overview-activity-logs
Activity Log is available in the Monitor SDK:
https://learn.microsoft.com/en-us/python/api/overview/azure/monitoring?view=azure-python
If you want to test this quickly, try the CLI:
https://learn.microsoft.com/en-us/cli/azure/monitor/activity-log?view=azure-cli-latest#az-monitor-activity-log-list
Since this CLI is using the same SDK, if you find your information with the CLI this means you can definitely get it with SDK
(I work at MS in the Python team, but not in the VM or Monitor team, it's why I start my post with "believe", but I really think it's accurate based on my knowledge of Azure)
Does anyone know if it is possible to specify the Kubernetes version when deploying ACS Kubernetes flavour?
If so how?
Using the supported resource provider in ARM you cannot specify the version. However, if you use http://github.com/Azure/acs-engine you can do so. ACS Engine is the open source code we (I work for MS) use to drive Azure Container Service. Using this code you have much more flexibility than you do through the published resource provider, but it's a harder onramp. For instructions see https://github.com/Azure/acs-engine/blob/master/docs/kubernetes.md
See examples at https://github.com/Azure/acs-engine/tree/master/examples/kubernetes-releases
You should use acs-engine and follow the deploy guide in the repo (https://github.com/Azure/acs-engine/blob/master/docs/kubernetes/deploy.md).
In the deploy guide they use the file examples/kubernetes.json and in that file there's -
"orchestratorProfile": {
"orchestratorType": "Kubernetes"
}
You can also add the field "orchestratorRelease": "1.7" for Kubernetes 1.7.
To view the whole list of releases available you can use the acs-engine executable and run acs-engine orchestrators that prints all of them.
Other examples can be found in https://github.com/Azure/acs-engine/tree/master/examples/kubernetes-releases