How do I delete all the resources within the subnet in cli? - azure-cli

Every time that I try to delete a subnet I got this type of error "Subnet testVMSubnet is in use by /subscriptions/testVMVMNic/ipConfigurations/ipconfigtestVM and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet."
So, how do I delete all the resources within the subnet?
[
{
"addressPrefix": "10.0.0.0/24",
"addressPrefixes": null,
"delegations": [],
"etag": "W/\"ba1ae732-1aa2-4d6d-af04-3dc6eaac8338\"",
"id": "/subscriptions/23c7f465-e27b-418b-b8a7-21616582f9bb/resourceGroups/user-qkyosxgoenbq/providers/Microsoft.Network/virtualNetworks/testVMVNET/subnets/testVMSubnet",
"interfaceEndpoints": null,
"ipConfigurationProfiles": null,
"ipConfigurations": [
{
"etag": null,
"id": "/subscriptions/23c7f465-e27b-418b-b8a7-21616582f9bb/resourceGroups/user-qkyosxgoenbq/providers/Microsoft.Network/networkInterfaces/testVMVMNic/ipConfigurations/ipconfigtestVM",
"name": null,
"privateIpAddress": null,
"privateIpAllocationMethod": null,
"provisioningState": null,
"publicIpAddress": null,
"resourceGroup": "user-qkyosxgoenbq",
"subnet": null
}
],
"name": "testVMSubnet",
"networkSecurityGroup": null,
"provisioningState": "Succeeded",
"purpose": null,
"resourceGroup": "user-qkyosxgoenbq",
"resourceNavigationLinks": null,
"routeTable": null,
"serviceAssociationLinks": null,
"serviceEndpointPolicies": null,
"serviceEndpoints": null,
"type": "Microsoft.Network/virtualNetworks/subnets"
}
]

Unfortunately there is no easy way to do this. If you have Network Watcher running in the region where your vnet is located than you can get the topology mapping to find out what is attached to that subnet using the command az network watcher show-topology -g MyResourceGroup. In addition to being only a single region, this only shows resource within a single resource group- items attached to the subnet from a different resource group won't show.
Theoretically you could parse this in order to create a list of delete scripts but this would be rather complex as each resource type has a different command to remove it. The solution depends greatly on how often you need to do this and scale. If it's a one-off, getting the list and manually deleting each item is probably simplest whether you do it from the portal or the cli. For an automated solution you may want to delete and redeploy the resource group or create a cleanup script to compliment your deployment scripts.

Related

Azure Resource Manager | Web App Slots Config | App Service Authentication

I successfully deployed my ARM template via ADO last week and realised that i forgot to include App Service Authentication for my Web App slots.
I messed around with the Microsoft.Web/sites/slots/config and ran into some errors that i was able to overcome with the help of few individuals on Stack.
However, now that the code should work it is failing but i am not getting any error codes on Azure DevOps when releasing.
It just says;
2020-07-02T14:20:19.0820320Z ##[error]At least one resource deployment operation failed. Please
list deployment operations for details. Please see https://aka.ms/DeployOperations for usage details.
2020-07-02T14:20:19.0832558Z ##[error]Details:
2020-07-02T14:20:19.0834149Z ##[error]BadRequest:
2020-07-02T14:20:19.0835776Z ##[error]Check out the troubleshooting guide to see if your issue is addressed: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/deploy/azure-resource-group-deployment?view=azure-devops#troubleshooting
2020-07-02T14:20:19.0837268Z ##[error]Task failed while creating or updating the template deployment.
Here is my code:
{
"type": "Microsoft.Web/sites/slots/config",
"name": "[concat(parameters('webAppName'),'/staging/auth')]",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[parameters('webAppName')]",
"[concat(parameters('sqlDatabase'), 'constr')]"
],
"properties": {
"enabled": true,
"runtimeVersion": "~1",
"unauthenticatedClientAction": "RedirectToLoginPage",
"tokenStoreEnabled": true,
"allowedExternalRedirectUrls": null,
"defaultProvider": "AzureActiveDirectory",
"clientId": null,
"clientSecret": null,
"clientSecretCertificateThumbprint": null,
"issuer": null,
"allowedAudiences": [
"https://webapptest1a-staging.azurewebsites.net"
],
"additionalLoginParams": null,
"isAadAutoProvisioned": false,
"googleClientId": null,
"googleClientSecret": null,
"googleOAuthScopes": null,
"facebookAppId": null,
"facebookAppSecret": null,
"facebookOAuthScopes": [
""
],
"twitterConsumerKey": null,
"twitterConsumerSecret": null,
"microsoftAccountClientId": null,
"microsoftAccountClientSecret": null,
"microsoftAccountOAuthScopes": [
""
]
}
},
Anything sticking out like a sore thumb?
I released the code without this part in it, and it worked fine, so it is most likely this little section here that is causing an issue, but all the information i believe is correct.
According to: https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2019-08-01/sites/config-authsettings
Thank you for your guidance.
So, after a bit i found an answer;
Here is the working code;
What i had previously done was this;
"name": "[concat(parameters('webAppName'), '/staging/auth')]",
What it needs to be is this;
"name": "[concat(parameters('webAppName'), '/staging/authsettings')]",
The "auth" alone will not match anything, and will give back a bad request. Which is right as nothing under "auth" exists meaning it cannot be matched.
So when you put Auth Settings, it actually works as intended as it matches!
Here is what i followed
{
"type": "Microsoft.Web/sites/slots/config",
"name": "[concat(parameters('webAppName'), '/staging/authsettings')]",
"apiVersion": "2018-11-01",
"location": "[resourceGroup().location]",
"dependsOn": [
"[parameters('webAppName')]",
"[concat(parameters('sqlDatabase'), 'constr')]"
],
"properties": {
"enabled": true,
"runtimeVersion": "1.0.0",
"unauthenticatedClientAction": "RedirectToLoginPage",
"tokenStoreEnabled": false,
"allowedExternalRedirectUrls": null,
"defaultProvider":"AzureActiveDirectory",
"clientId": null,
"clientSecret": null,
"clientSecretCertificateThumbprint": null,
"issuer": null,
"allowedAudiences": null,
"additionalLoginParams": null,
"isAadAutoProvisioned": false,
"googleClientId": null,
"googleClientSecret": null,
"googleOAuthScopes": null,
"facebookAppId": null,
"facebookAppSecret": null,
"facebookOAuthScopes": [
""
],
"twitterConsumerKey": null,
"twitterConsumerSecret": null,
"microsoftAccountClientId": null,
"microsoftAccountClientSecret": null,
"microsoftAccountOAuthScopes": [
""
]
}
},

BIM360 Project's Service Type undocumented

On GET projects from BIM360, service_typesproperty contains services no documented.
Making a GET request to BIM360 Projects (https://forge.autodesk.com/en/docs/bim360/v1/reference/http/projects-:project_id-GET/), the service_types returns additional values than those documented on https://forge.autodesk.com/en/docs/bim360/v1/overview/parameters/#service-type
{
"id": "{PROJECT_ID}",
"account_id": "{ACCOUNT_ID}",
"name": "Sample Project",
"start_date": "2019-09-25",
"end_date": "2019-10-25",
"value": null,
"currency": null,
"status": "active",
"job_number": null,
"address_line_1": null,
"address_line_2": null,
"city": null,
"state_or_province": null,
"postal_code": null,
"country": "United States",
"business_unit_id": null,
"created_at": "2019-09-25T14:26:04.092Z",
"updated_at": "2019-10-04T16:44:25.271Z",
"project_type": "Demonstration Project",
"timezone": null,
"language": "en",
"construction_type": null,
"contract_type": null,
"last_sign_in": "2019-10-04T16:44:25.000Z",
"service_types": "doc_manager,insight,admin"
}
According to the documentation, only field, glue, schedule, plan and doc_managerare expected.
So at the moment the situation is that those services are not properly documented since they are not fully supported yet. They are actively working in making this services better and documented properly. There is an improvement process being worked on this quarter. Check back with us in a near future, a good structure and improvement to the bim360 service is coming. thank you for reaching out.

Get host status by CheckMK Web-API

I'm trying to get the status of a host with the CheckMK WebAPI. Can someone point me in the right direction how to get these data?
We're currently using CheckMK enterprise 1.4.0.
I've tried:
https://<monitoringhost.tld>/<site>/check_mk/webapi.py?action=get_host&_username=<user>&_secret=<secret>&output_format=json&effective_attributes=1&request={"hostname": "<hostname>"}
But the response does not have any relevant information about the host itself (e.g. state up/down, uptime, etc.).
{
"result": {
"attributes": {
"network_scan": {
"scan_interval": 86400,
"exclude_ranges": [],
"ip_ranges": [],
"run_as": "api"
},
"tag_agent": "cmk-agent",
"snmp_community": null,
"ipv6address": "",
"alias": "",
"management_protocol": null,
"site": "testjke",
"tag_address_family": "ip-v4-only",
"tag_criticality": "prod",
"contactgroups": [
true,
[]
],
"network_scan_result": {
"start": null,
"state": null,
"end": null,
"output": ""
},
"parents": [],
"management_address": "",
"tag_networking": "lan",
"ipaddress": "",
"management_snmp_community": null
},
"hostname": "<host>",
"path": ""
},
"result_code": 0
The webapi is only for getting/setting the configuration of a host or other objects. If you want't to get the live status of a host use livestatus.
If you enabled livestats on port 6557 (default) you could query the status of a host via network. If you are logged into a shell locally you can use 'lq'.
OMD[mysite]:~$ lq "GET hosts\nColumns: name"
Why:
The CheckMK webapi if for accessing WATO. WATO is the source for creating the nagios configuration. Nagios will do the monitoring of the hosts and the livestatus api is an extension of the nagios core.
http://<monitoringhost.tld>/<site>/check_mk/view.py?view_name=allhosts&output_format=csv
You can use all the views that you see in the webui by adding output_format=[csv|json|python].
You will the data of the table that you see.
You also need to add the creditals as seen in yout question.

Loading JSON data with apostrophe (single quote) i

This is specifically regarding insert of data into CrateDB,
I have a table with one column of type OBJECT. I am trying to insert JSON data into that using python and it is going along fine.
create table users (userdata OBJECT);
However, my data has apostrophe's in it i.e. single quotes and so the insert is failing. I have replicated the problem on the console:
The problem in the data below is with the "snr" field. I have tried putting in a backslash but that does not help.
Can someone tell me how I can get the following insert to
INSERT into users (userdata)
VALUES ('{"area_code": "2", "companyname": "TEC", "cos": "National24Hrs-Standard",
"country_code": "AUS", "cucm_dn": "26902", "ddi": "84236902", "department": null,
"device_type": "Cisco 8945 SIP", "divisionname": "Demonstrations",
"emailaddress": "bart.simpson#core.demo.telstra.com", "extension": "26902",
"extra1": null, "extra2": null, "extra3": null, "extra4": null,
"featuregroup": "Mobile Worker", "firstname": "Bart", "information": null,
"ippbxchosen": "TEC-CL-1", "language": "English - United States", "lastname": "Simpson",
"locationname": "Sydney", "mask": "61284236902", "pickupgroup": null, "postcode": "2000",
"presence": "Y", "role": "enduser", "security_profile": "EndUser-SP1",
"snr": "Bart\'s Mobile:0457503561,Bart Simpson:457503561",
"username": "bart.simpson#core.demo.telstra.com", "voicemail": "UCX-Advanced-CoS"}')
Inserting a JSON string into a CrateDB object typed column will always fail, this has afaik nothing to do with wrong escaping in your case. Either insert this as an CrateDB object (which I guess is what you want) to gain the benefits of accessing/searching each key/value, or change the data type to string.
See documentation about using object literals https://crate.io/docs/crate/reference/en/latest/general/ddl/data-types.html#object-literals.
Also most CrateDB client drivers do support binding data as objects.

"sequence_id" in Box.com Create Folder API call

In Box.com API document it is written that, if you will create a folder then you will get some response.
So I have gone through the response, and wondering what is "sequence_id" means in this block of of code.
"parent": {
"type": "folder",
"id": "0",
"sequence_id": null,
"etag": null,
"name": "All Files"
},
Regards
The folder with id=0 is the users "root" folder. As such it isn't a real folder with an etag or a sequence_id. Every other folder at every other level will have a non-zero id, and will have a sequence_id and a non-null etag.