Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Exploring Status

Mayur Tendulkar mayur-tendulkar

💭
Exploring Status
View GitHub Profile
@mayur-tendulkar
mayur-tendulkar / CreateVM.cs
Created Dec 25, 2018
Create VM using Fluent API
View CreateVM.cs
var windowsVM = azure.VirtualMachines.Define("myWindowsVM")
.WithRegion(Region.US_EAST)
.WithNewResourceGroup(rgName)
.WithNewPrimaryNetwork("10.0.0.0/28")
.WithPrimaryPrivateIpAddressDynamic()
.WithNewPrimaryPublicIpAddress("mywindowsvmdns")
.WithPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER)
.WithAdminUserName("tirekicker")
.WithPassword(password)
.WithSize(VirtualMachineSizeTypes.StandardD3V2)
@mayur-tendulkar
mayur-tendulkar / StorageHttpsPolicyFunction.cs
Created Dec 25, 2018
Azure Function for Storage Account HTTPs Only Policy
View StorageHttpsPolicyFunction.cs
using System;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
@mayur-tendulkar
mayur-tendulkar / AlertFormat.json
Created Dec 25, 2018
Activity Log Alert Format
View AlertFormat.json
{
"schemaId": "Microsoft.Insights/activityLogs",
"data": {
"status": "Activated",
"context": {
"activityLog": {
"authorization": {
"action": "Microsoft.Storage/storageAccounts/write",
"scope": "/subscriptions/<subcription-id-hidden>/resourceGroups/SubscriptionMonitoring/providers/Microsoft.Storage/storageAccounts/submonstore"
},
View AZR-ListAllAzureServicesNew.cs
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Fetching service listing...");
Console.ReadKey();
Task.Run(async () => FetchRecords());
Console.ReadKey();
}
View ARM-Blog-GetUsage.cs
var requestUrl = String.Format("https://management.azure.com/subscriptions/{0}/providers/Microsoft.Commerce/UsageAggregates?
api-version=2015-06-01-preview&reportedStartTime={1}&reportedEndTime={2}&aggregationGranularity=Daily&showDetails=false",
App.SelectedSubscription.SubscriptionId, startTime, endTime);
var usageData = await client.GetStringAsync (requestUrl);
var data = JsonConvert.DeserializeObject<AzureTracker.Model.UsageResponse> (usageData);
View ARM-Blog-GetSubscriptions.cs
private async Task GetSubscriptions(string tenantId)
{
var requestUrl = "https://management.azure.com/subscriptions?api-version=2015-01-01";
try {
var data = await DependencyService.Get<IAuthenticator> ().AuthenticateSilently (tenantId,
App.ManagementResourceUri, App.ClientId);
client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", data.AccessToken);
var subsriptionResponse = await client.GetStringAsync (requestUrl);
var subscriptions = JsonConvert.DeserializeObject<SubscriptionResponse>(subsriptionResponse);
foreach (var subscription in subscriptions.SubscriptionCollection) {
View ARM-Blog-GetTenants.cs
private async Task GetTenants()
{
var requestUrl = "https://management.azure.com/tenants?api-version=2015-01-01";
try {
var tenantResponse = await client.GetStringAsync(requestUrl);
tenantCollection = JsonConvert.DeserializeObject<TenantResponse> (tenantResponse);
}
catch (Exception ex) {
await DisplayAlert("Error!", ex.Message, "Dismiss");
}
@mayur-tendulkar
mayur-tendulkar / Plugin-Blog-Accelerometer-Forms.cs
Created Mar 9, 2015
Using Accelerometer in Xamarin.Forms Applications
View Plugin-Blog-Accelerometer-Forms.cs
private void BtnStart_OnClicked(object sender, EventArgs e)
{
CrossDeviceMotion.Current.Start(MotionSensorType.Accelerometer, MotionSensorDelay.Ui);
CrossDeviceMotion.Current.SensorValueChanged += (s, a) =>
{
switch (a.SensorType)
{
case MotionSensorType.Accelerometer:
lblXAxis.Text = ((MotionVector)a.Value).X.ToString("F");
@mayur-tendulkar
mayur-tendulkar / Plugin-Blog-Accelerometer-iOS.cs
Created Mar 9, 2015
Using Accelerometer in iOS Applications
View Plugin-Blog-Accelerometer-iOS.cs
public override void ViewDidLoad()
{
base.ViewDidLoad();
_motionManager = new CMMotionManager();
_motionManager.StartAccelerometerUpdates(NSOperationQueue.CurrentQueue, (data, error) =>
{
lblXAxis.Text = data.Acceleration.X.ToString("F");
lblYAxis.Text = data.Acceleration.Y.ToString("F");
lblZAxis.Text = data.Acceleration.Z.ToString("F");
});
@mayur-tendulkar
mayur-tendulkar / Plugin-Blog-Accelerometer-Android.cs
Created Mar 9, 2015
Using Accelerometer in Android Applications
View Plugin-Blog-Accelerometer-Android.cs
[Activity(Label = "Accelerometer_Droid", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity, ISensorEventListener
{
private SensorManager _sensorManager;
private static readonly object _syncLock = new object();
private TextView x_axis; private TextView y_axis; private TextView z_axis;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);