예제 #1
0
        public async Task <bool> CreateAppService(string subscriptionId, string resourceGroupName, string servicePlanName, string appServiceName, string location)
        {
            string servicePlanId = GetUri(ServicePlanId, subscriptionId, resourceGroupName, servicePlanName);
            string appServiceUrl = GetUri(WebAppUri, subscriptionId, resourceGroupName, appServiceName);

            AppServiceObject aso = new AppServiceObject()
            {
                kind       = "app",
                properties = new AppServiceObject.Properties()
                {
                    serverFarmId = servicePlanId,
                },
                location = location
            };
            string body = JsonConvert.SerializeObject(aso);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    string response = await AzureRequest.GetResponse(appServiceUrl, azureAccessToken, HttpMethods.PUT, null, body);
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }));
        }
예제 #2
0
        public async Task <bool> CreateServicePlan(string subscriptionId, string resourceGroupName, string servicePlanName, string location)
        {
            string url = GetUri(ServicePlanUri, subscriptionId, resourceGroupName, servicePlanName);

            ServicePlanObject spo = new ServicePlanObject()
            {
                kind = "app",
                sku  = new ServicePlanObject.Sku()
                {
                    name = "S1",
                    tier = "Standard",
                    size = "S1"
                },
                location = location,
            };
            string body = JsonConvert.SerializeObject(spo);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    string response = await AzureRequest.GetResponse(url, azureAccessToken, HttpMethods.PUT, null, body);
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }));
        }
예제 #3
0
        public async Task <string> GetWebAppPublishProfile(string subscriptionId, string resourceGroupName, string webAppName)
        {
            string url = GetUri(WebAppPublishProfile, subscriptionId, resourceGroupName, webAppName);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    return await AzureRequest.GetResponse(url, azureAccessToken, HttpMethods.POST, null);
                }
                catch (WebException)
                {
                    return string.Empty;
                }
            }));
        }
예제 #4
0
        public async Task <bool> GetResourceGroup(string subscriptionId, string resourceGroupName)
        {
            string url = GetUri(ResourceGroupUri, subscriptionId, resourceGroupName);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    string response = await AzureRequest.GetResponse(url, azureAccessToken, HttpMethods.HEAD);
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }));
        }
예제 #5
0
        public async Task <bool> DeleteAppService(string subscriptionId, string resourceGroupName, string appServiceName)
        {
            string url = GetUri(WebAppDeleteUri, subscriptionId, resourceGroupName, appServiceName);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    string response = await AzureRequest.GetResponse(url, azureAccessToken, HttpMethods.DELETE);
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }));
        }
예제 #6
0
        public async Task <bool> DeleteServicePlan(string subscriptionId, string resourceGroupName, string servicePlanName)
        {
            // TODO: Need to delete all the apps inside ServicePlan, ServicePlan with app can't be deleted unless it's empty
            // string listUrl = GetUri(ServicePlanUriListApps, subscriptionId, resourceGroupName, servicePlanName);

            string url = GetUri(ServicePlanUri, subscriptionId, resourceGroupName, servicePlanName);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    string response = await AzureRequest.GetResponse(url, azureAccessToken, HttpMethods.DELETE);
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }));
        }
예제 #7
0
        public async Task <bool> CreateResourceGroup(string subscriptionId, string resourceGroupName, string location)
        {
            string url = GetUri(ResourceGroupUri, subscriptionId, resourceGroupName);

            ResourceGroupObject rgo = new ResourceGroupObject()
            {
                id       = string.Format(ResourceGroupId, subscriptionId, resourceGroupName),
                location = location,
                name     = resourceGroupName
            };
            string body = JsonConvert.SerializeObject(rgo);

            return(await ExecuteWithRetryTokenRefresh(async (azureAccessToken) => {
                try
                {
                    string response = await AzureRequest.GetResponse(url, azureAccessToken, HttpMethods.PUT, null, body);
                    return true;
                }
                catch (WebException)
                {
                    return false;
                }
            }));
        }